/**
 * 框架js,tool为系统变量,请勿在其他页面者重新初始化
 * Created by tengchong on 15/7/21.
 */
/**
 * page 二级页面对象,切换菜单将重新初始化
 * subPage 三级页面对象,切换菜单将重新初始化
 * @type {{}}
 */
var page = {},
    subPage = {};
var subview_id = [];
var jsonlanguagemain = null;
var cookielang = null;
/**
 * tool 工具对象
 * @type {{hideMenu: null, choseLeftStageMenu: string, choseTopStageMenu: string, leftStageMenuList: Array, menuList: Array, res_form: null, configDebug: boolean, userloginid: null, usertype: null, waitForResponseStatusBtn: null, submitForm: tool.submitForm, loadFormByTr: tool.loadFormByTr, showAllQueryTeam: tool.showAllQueryTeam, resetForm: tool.resetForm, importData: tool.importData, exportData: tool.exportData, exportDataForDbf: tool.exportDataForDbf, exportDataByForm: tool.exportDataByForm, exportDataByFormForDbf: tool.exportDataByFormForDbf, getChoseData: tool.getChoseData, CropCheckBoxValueAsString: tool.CropCheckBoxValueAsString, editData: tool.editData, editDataById: tool.editDataById, addData: tool.addData, addDataByLcbm: tool.addDataByLcbm, addDataBackByLcbm: tool.addDataBackByLcbm, saveData: tool.saveData, getTop: tool.getTop, openSubviewByForm: tool.openSubviewByForm, alertLogin: tool.alertLogin, alert: tool.alert, alertInfo: tool.alertInfo, alertSuccess: tool.alertSuccess, alertError: tool.alertError, alertWarning: tool.alertWarning, alertConfirm: tool.alertConfirm, openSubview: tool.openSubview, doRemove: tool.doRemove, deleteDataById: tool.deleteDataById, deleteData: tool.deleteData, doSearch: tool.doSearch, initOrderTables: tool.initOrderTables, initOrderTable: tool.initOrderTable, initSubViewBox: tool.initSubViewBox, addRow: tool.addRow, initEditRow: tool.initEditRow, initSaveRow: tool.initSaveRow, initDelRow: tool.initDelRow, save_row: tool.save_row, openloading: tool.openloading, closeloading: tool.closeloading, del_row: tool.del_row, edit_row: tool.edit_row, initFileUpload: tool.initFileUpload, openModal: tool.openModal, modal: tool.modal, randomString: tool.randomString, getString: tool.getString, submit_save: tool.submit_save, super_doSearch: tool.super_doSearch, doModify: tool.doModify, openview: tool.openview, openEntity: tool.openEntity, super_reset: tool.super_reset, downloadfile: tool.downloadfile, initParams: tool.initParams, setWaitForResponseStatus: tool.setWaitForResponseStatus, removeWaitForResponseStatus: tool.removeWaitForResponseStatus, showWaitTip: tool.showWaitTip, setWaitTip: tool.setWaitTip, hideWaitTip: tool.hideWaitTip, isNotEmpty: tool.isNotEmpty, isEmpty: tool.isEmpty, isDebug: tool.isDebug, emptyHtml: tool.emptyHtml, emptyValue: tool.emptyValue, emptyTextarea: tool.emptyTextarea, report: tool.report, report_s: tool.report_s, report_all: tool.report_all, report_open: tool.report_open, report_open_input: tool.report_open_input, getlog: tool.getlog, getlog_htm: tool.getlog_htm, timeout_import: null, times_import: number, openimport: tool.openimport, initimport: tool.initimport, closeimport: tool.closeimport, importtimes: tool.importtimes, initbtnQx: tool.initbtnQx, initbtnQxBack: tool.initbtnQxBack, deleteFileRow: tool.deleteFileRow, addUploadAttachmentRow: tool.addUploadAttachmentRow, addUploadImageRow: tool.addUploadImageRow, previewImage: tool.previewImage, initFileIcon: tool.initFileIcon, getFileIcon: tool.getFileIcon, validationElement: tool.validationElement}}
 */
var tool = {
    hideMenu: null,
    choseLeftStageMenu: '1',
    choseTopStageMenu: '1',
    leftStageMenuList: [],
    menuList: [],
    res_form: null,
    configDebug: true,
    userloginid: null,
    usertype: null,//用户操作权限
    waitForResponseStatusBtn: null,
    procee: '/pros/',
    /**
     * 提交表单 for search
     * @param form_element 要提交表单的对象 | 不可为空
     */
    submitForm: function (form_element) {
        var el = form_element.parents(".panel");
        if (el.length != 0) {
            el.block({
                overlayCSS: {
                    backgroundColor: '#fff'
                },
                message: '<i class="fa fa-spinner fa-spin"></i>',
                css: {
                    border: 'none',
                    color: '#333',
                    background: 'none'
                }
            });
        }
        $.ajax({
            url: tool.initParams(form_element.attr("data-action")),
            cache: false,
            type: "post",
            data: form_element.serialize(),
            dataType: "html",
            timeout: 1000 * 15,
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                el.unblock();
                tool.alertWarning('请求超时!', '请稍后重试!');
            },
            success: function (data) {
                el.unblock();
                if (form_element.attr("data-action").indexOf("excelUserImport-list") > -1) {
                    form_element.find(".dataTables_wrapper").html(data);
                } else {
                    //更新表格内容
                    form_element.find(".dataTables_wrapper").eq(0).html($(data).find(".form-horizontal .dataTables_wrapper").eq(0).html());//刷新table > list
                    //更新分页信息
                    form_element.find(".page-info:eq(0)").html($(data).find(".form-horizontal .page-info:eq(0)").html());
                    form_element.find(".page-info:eq(1)").html($(data).find(".form-horizontal .page-info:eq(1)").html());
                    //更新汇总信息
                    el.find("#text-bold-cdmc").html($(data).find("#text-bold-cdmc").html());
                }
                form_element.find(".page-info:eq(0)")
                Main.initList(form_element.find("table"));
                initselectcode();
                init_lanagure();
            }
        });
    },
    /**
     * 通过点击tr在form下面加载新list
     */
    loadFormByTr: function (el, url, type) {
        var form_element = $(el).parents('.form-horizontal');
        if (type == '1') form_element = $(el).parents('.form-horizontal-tr');
        var el = form_element.parents(".panel");
        if (el.length != 0) {
            el.block({
                overlayCSS: {
                    backgroundColor: '#fff'
                },
                message: '<i class="fa fa-spinner fa-spin"></i>',
                css: {
                    border: 'none',
                    color: '#333',
                    background: 'none'
                }
            });
        }
        var data = '';
        if (form_element.attr('data-action') == url) {
            data = form_element.serialize()
        }
        $.ajax({
            url: tool.initParams(url),
            cache: false,
            type: "post",
            data: data,
            dataType: "html",
            timeout: 1000 * 15,
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                el.unblock();
                tool.alertError('请求超时!', '请稍后重试!');
            },
            success: function (data) {
                el.unblock();
                var htm = '<form method="post" class="form-horizontal-tr">' +
                    '<input type="hidden" id="orderType" name="orderType" value="${orderType}">' +
                    '<input type="hidden" id="orderField" name="orderField" value="${orderField}">' + data + '</form>';
                var this_element = null;
                if (form_element.attr('data-action') == url) {
                    form_element.html(htm);
                    this_element = form_element;
                } else {
                    if (form_element.next('.form-horizontal-tr').html() != undefined) {
                        form_element.next('.form-horizontal-tr').html(htm);
                    } else {
                        form_element.after(htm);
                    }

                    this_element = form_element.next('.form-horizontal-tr');
                }
                Main.initList(this_element.find("table tbody"));
                this_element.attr("data-action", url);
                initselectcode();
                if (url.indexOf("action") < 0) {//spring mvc
                    this_element.find("#yspager_currentPageno").attr("name", "currentPageno");
                    this_element.find("#eachPageRows").attr("name", "eachPageRows");
                }
                this_element.find("ul[class*='pagination']").find('a').each(function () {
                    $(this).attr("data-current-page-no-tr", $(this).attr("data-current-page-no"));
                    $(this).removeAttr("data-current-page-no");
                    $(this).unbind('click');
                });
                this_element.find("ul[class*='pagination']").find('a[data-current-page-no-tr]').click(function () {
                    var form_element = $(this).parents(".form-horizontal-tr");
                    form_element.find("#yspager_currentPageno").val($(this).attr("data-current-page-no-tr"));
                    tool.loadFormByTr(this, url, '1');
                });
            }
        });
    },
    /**
     * 用于查询条件超过2行时,显示隐藏多余的查询条件
     * 注:需要在需要隐藏/显示的元素上添加class 'more-query'
     * @param el 显示更多查询条件按钮 | 不可为空
     */
    showAllQueryTeam: function (el) {
        if ($(el).attr("data-state") == "open") {
            $(el).parents('.form-horizontal').find(".more-query").addClass("animated fadeOutUp").one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function () {
                $(el).parents('.form-horizontal').find(".more-query").removeClass("animated fadeOutUp").addClass("dn");
            });
            $(el).removeAttr("data-state");
            $(el).html("显示更多查询条件 <i class=\"fa fa-angle-down\"></i>");
        } else {
            $(el).parents('.form-horizontal').find(".more-query").removeClass("dn").addClass("animated fadeInUp").one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function () {
                $(el).parents('.form-horizontal').find(".more-query").removeClass("animated fadeInUp");
            });
            $(el).attr("data-state", "open");
            $(el).html("收起更多查询条件 <i class=\"fa fa-angle-up\"></i>");
        }
    },
    /**
     * 重置查询条件
     * @param el 重置按钮 | 不可为空
     */
    resetForm: function (el) {
        $(el).parents('.form-horizontal').find("input:visible,select:visible").val("");
        $(el).parents('.form-horizontal').find("select:visible").trigger("change");
    },
    /**
     * 打开导入页面
     * @param el 导入按钮 | 不可为空
     * @param par 参数 | 一般传入导入模板id
     */
    importData: function (el, par) {
        var form_element = $(el).parents('.form-horizontal');
        tool.res_form = form_element;
        var subview_box = tool.initSubViewBox(form_element);
        var url = basePath + "/system/excelUserImport-input.action?" + par;
        tool.openSubview(url, subview_box, false);
    },
    /**
     * 在iframe中打开导出页面
     * @param par 地址+参数 | 不可为空
     */
    exportData: function (par, path,filep) {
        if (path == null || path == '') path = basePath;
        tool.openloading(null, '下载中，请等待...');
        var nomodal=true;
        var jsp =par;
        if(par.indexOf('.jsp')!=-1){
        	 jsp = par.substring(0, par.indexOf('.jsp') + 4);
        	 nomodal=false;
        } 
        
        var tj = '';
        if (par.indexOf('?') != -1) {
            tj = par.substring(par.indexOf('?') + 1);
        }
//        $.ajax({
//            url: path + "/export2excel/" + jsp,
//            cache: false,
//            type: "post",
//            data: tj,
//            timeout: 1000 * 60,
//            error: function (XMLHttpRequest, textStatus, errorThrown) {
//            	tool.alert('网络连接异常！请刷新页面重试。');
//                tool.closeloading(null);
//            },
//            success: function (data) {
//            	$("#export-iframe").attr("src", path + "/export2excel/" + jsp.replace('.jsp','_download.jsp'));
//                tool.closeloading(null);
//            }
//        });
        var form = $("<form>");        //定义一个form表单
        if (document.getElementById('exportDataForm')) {
            form = $('#exportDataForm');
        } else {
            $("body").append(form); //将表单放置在web中
        }
        form.attr("id", "exportDataForm");        //表单默认隐藏
        form.attr("style", "display:none");        //表单默认隐藏
        form.attr("method", "post");

        form.attr("action", path + "/"+filep+"/" + jsp);        //后台路径
        form.find('input').remove();
        var param = '';
        if (tj != '') {
            var tjarr = tj.split('&');
            for (var i = 0; i < tjarr.length; i++) {
                var op = tjarr[i].split('=');
                var input = $("<input>");        //定义agreementid的input
                input.attr("type", "hidden");        //默认隐藏
                input.attr("name", op[0].trim());
                input.attr("value", op[1].trim());
                form.append(input);
                if(param!='') param += "!@#";
                param += op[1].trim();
            }
        }
        $.post(basePath + '/s/ajax/getnownew', {'param':param}, function (data) {
            var inputnew = $("<input>");        //定义agreementid的input
            inputnew.attr("type", "hidden");        //默认隐藏
            inputnew.attr("name", "nownew");
            inputnew.attr("value", data);
            form.append(inputnew);
            form.submit();//表单提交
            tool.exportSuccess_time = 2000;
            tool.exportSuccess_c = 1;
            setTimeout('tool.exportSuccess(\'' + path + '\')', tool.exportSuccess_time);
        });
        
       
    },
    exportSuccess_time:0,
    exportSuccess_c:0,
    exportSuccess: function (path) {
    	if(tool.exportSuccess_time<10000) tool.exportSuccess_time += 1000;
    	tool.exportSuccess_c += 1;
    	if(tool.exportSuccess_c>=50){
    		 tool.closeloading(null);
    		 return false;
    	}
        $.post(path + '/s/ajax/exportSuccess', {}, function (data) {
            if (data == 'true') {
                tool.closeloading(null);
            } else {
            	setTimeout('tool.exportSuccess(\'' + path + '\')', tool.exportSuccess_time);
            }
        });

    },
    /**
     * 在iframe中打开导出页面
     * @param par 地址+参数 | 不可为空
     */
    exportDataForDbf: function (par, path) {
        if (path == null || path == '') path = basePath;
        window.parent.tool.exportData(par, path,'export2dbf');
    },
    /**
     * 导出数据 (将导出按钮所在form表单数据作为参数通过url传入)
     * @param el this
     * @param par 参数
     * @param path url
     */
    exportDataByForm: function (el, par, path, is_dbf) {
        if ((path == null || path == '') && nodePath != null && nodePath != '') path = nodePath;
        var form_element = $(el).parents('.form-horizontal');
        var temp = '';
        var elList = form_element.find('input[type="text"],select');
        elList.each(function () {
            var $el = $(this);
            temp += $el.attr('name') + '=' + $el.val() + '&';
        });
        if (elList.length > 0) {
            temp = temp.substr(0, temp.length - 1);
        }
        if (par.indexOf('?') > -1) {
            par = par + '&' + temp
        } else {
            par = par + '?' + temp
        }
        if (is_dbf) {
            tool.exportDataForDbf(par, path);
        } else {
            tool.exportData(par, path);
        }

    },
    /**
     * * 获取所选数据
     * @param form_element 表单(jquery对象) | 不可为空
     * @returns {string} 选中数据的id | 示例 1,2,3,4
     */
    getChoseData: function (form_element) {
        var selectNode = form_element.find('input[name="selectNode"]:checked');
        var ids = '';
        if (!isBlank(selectNode)) {
            for (var i = 0; i < selectNode.length; i++) {
                ids += $(selectNode[i]).val() + ',';
            }
            ids = ids.substr(0, ids.length - 1);
        }
        return ids;
    },
    /**
     * 获取当前form中指定名称的checkbox选中列表
     * @param name checkbox名称 | 不可为空
     * @param el 按钮 | 不可为空
     * @returns {string} 选中数据的id | 示例 1,2,3,4
     */
    CropCheckBoxValueAsString: function (name, el) {
        var form_element = $(el).parents('.form-horizontal');
        var selectNode = form_element.find("input[name='" + name + "']:checked");
        var ids = "";
        if (!isBlank(selectNode)) {
            for (var i = 0; i < selectNode.length; i++) {
                ids += $(selectNode[i]).val() + ",";
            }
            ids = ids.substr(0, ids.length - 1);
        }
        return ids;
    },
    youdaoLanguage: function (txt) {
        try {
            if (cookielang == "en") {
                $.ajax(
                    {
                        type: 'post',
                        url: '/pros/s/ajax/getyoudaovalue?txt=' + encodeURI(encodeURI(txt)),
                        dataType: 'text',
                        async: false,
                        success: function (data) {
                            txt = data;
                        },
                        error: function () {
                            console.log('fail');
                        }
                    }
                );
            }
        } catch (e) {
            // TODO: handle exception
        }

        return txt;
    },
    /**
     * 修改数据
     * @param el 修改按钮 | 不可为空 | 示例 this
     * @param subview_box 子窗口容器 | 可为空
     */
    editData: function (el, subview_box) {
        var form_element = $(el).parents('.form-horizontal');
        tool.res_form = form_element;
        var ids = tool.getChoseData(form_element);
        if (!isBlank(ids)) {
            if (ids.split(",").length == 1) {
                tool.editDataById(el, ids, subview_box);
            } else {
                tool.alertWarning('不支持批量修改,请勾选1条数据!', '请在下方列表中勾选一条要修改的数据');
            }
        } else {
            tool.alertWarning('请选择要修改的数据!', '请在下方列表中勾选一条要修改的数据');
        }
    },
    /**
     * 根据id修改信息
     * @param el 链接 | 不可为空 | 示例 this
     * @param id 数据id | 不可为空
     * @param subview_box 子页面容器 | 可为空
     */
    editDataById: function (el, id, subview_box) {
        var form_element = $(el).parents('.form-horizontal');
        tool.res_form = form_element;
        var url = form_element.attr("data-action");
        if (url.indexOf("action") < 0) {
            url = url.substring(0, url.indexOf('/s/') + 7) + url.substring(url.indexOf('/s/') + 7).substring(0, url.substring(url.indexOf('/s/') + 7).indexOf("/"));
            url = url + "/input/" + id;
        } else {
            url = url.substr(0, url.indexOf("-")) + "-input.action?wid=" + id;
        }
        subview_box = tool.initSubViewBox(form_element, subview_box);
        tool.openSubview(url, subview_box, true);
    },
    /**
     * 新增数据 注:form中class中包含parameter的将会自动作为参数传到后台
     * @param el 必填 | 当前form中的一个元素
     * @param parameter 参数 | 可选
     * @param subview_box 页面容器 | 可选
     */
    addData: function (el, parameter, subview_box, lcsearch) {
        var form_element = $(el).parents('.form-horizontal');
        tool.res_form = form_element;
        var data = form_element.find('input[class*="parameter"],select[class*="parameter"]').serialize();
        var url = form_element.attr('data-action');
        if (url.indexOf('action') < 0) {
            url = url.substring(0, url.indexOf('/s/') + 7) + url.substring(url.indexOf('/s/') + 7).substring(0, url.substring(url.indexOf('/s/') + 7).indexOf('/'));
            url = url + '/openCreate?time=' + new Date().getTime();
            if (parameter != null && parameter != '') {
                url += '&' + parameter;
            }
            if (lcsearch != null && lcsearch != '') {
                url += '&' + lcsearch;
            } else if (data != null && data != '') {
                url += '&' + data;
            }
        } else {
            url = url.substr(0, url.indexOf('-')) + '-openCreate.action?time=' + new Date().getTime();

            if (parameter != null && parameter != '') {
                url += '&' + parameter;
            }
            if (lcsearch != null && lcsearch != '') {
                url += '&' + lcsearch;
            } else if (data != null && data != '') {
                url += '&' + data;
            }
        }
        subview_box = tool.initSubViewBox(form_element, subview_box);
        tool.setWaitForResponseStatus($(el));
        tool.openSubview(url, subview_box, true);
    },
    /**
     * 新增数据，查看工作流有没有配置年度，配置了则打开数据
     */
    addDataByLcbm: function (el, lcbm, parameter, subview_box, name, tool_ch) {
        $.post(tool.initParams(tool.procee + 's/biz/ajaxProcess/opennd'), {'lcbm': lcbm}, function (data) {
            var a = 0;
            var htm = '';
            var old = false;
            $(data).each(function (i) {
                if (data[i].wid == 'old') {
                    old = true;
                }
                if (!old) {
                    a++;
                    htm += '<a name="addDataByLcbm" class="btn btn-sm btn-green" onclick="" con="' + data[i].con + '">' + data[i].conMs + '</a>&nbsp;';
                }
            });
            if (old) {
                tool.alertWarning('不可以操作', '当前时间不在管理员开启的时间范围内，请联系管理员！');
            } else {
                if (a == 0) {
                    if (tool_ch != null) {
                        tool_ch.addData(el, parameter, subview_box, name, null);
                    } else {
                        tool.addData(el, parameter, subview_box, null);
                    }
                } else if (a == 1) {
                    if (tool_ch != null) {
                        tool_ch.addData(el, parameter, subview_box, name, $(this).attr('con').replaceAll('and', '&').replaceAll('\'', '').replaceAll(' ', ''));
                    } else {
                        tool.addData(el, parameter, subview_box, data[0].con.replaceAll('and', '&').replaceAll('\'', '').replaceAll(' ', ''));
                    }
                } else {
                    swal({
                        title: "请选择条件",
                        text: htm,
                        html: true,
                        showCancelButton: true,
                        showConfirmButton: false
                    });
                    $('a[name*="addDataByLcbm"]').click(function () {
                        if (tool_ch != null) {
                            tool_ch.addData(el, parameter, subview_box, name, $(this).attr('con').replaceAll('and', '&').replaceAll('\'', '').replaceAll(' ', ''));
                        } else {
                            tool.addData(el, parameter, subview_box, $(this).attr('con').replaceAll('and', '&').replaceAll('\'', '').replaceAll(' ', ''));
                        }
                        swal.close();
                    });
                }
            }
        });


    },
    /**
     * 新增数据，查看工作流有没有配置年度，配置了则打开数据,返回调用子项目方法
     */
    addDataBackByLcbm: function (el, lcbm, parameter, subview_box, name, p) {
        $.post(tool.initParams(tool.procee + 's/biz/ajaxProcess/opennd'), {'lcbm': lcbm}, function (data) {
            var a = 0;
            var htm = '';
            $(data).each(function (i) {
                a++;
                htm += '<a name="addDataBackByLcbm" class="btn btn-sm btn-green" onclick="" con="' + data[i].con + '">' + data[i].conMs + '</a>&nbsp;';
            });
            if (a == 0) {
                if (tool_ch != null) {
                    tool_ch.addData(el, parameter, subview_box, name, null);
                } else {
                    tool.addData(el, parameter, subview_box, null);
                }
            } else if (a == 1) {
                if (tool_ch != null) {
                    tool_ch.addData(el, parameter, subview_box, name, $(this).attr('con').replaceAll('and', '&').replaceAll('\'', '').replaceAll(' ', ''));
                } else {
                    tool.addData(el, parameter, subview_box, data[0].con.replaceAll('and', '&').replaceAll('\'', '').replaceAll(' ', ''));
                }
            } else {
                swal({
                    title: "请选择条件",
                    text: htm,
                    html: true,
                    showCancelButton: true,
                    showConfirmButton: false
                });
                $('a[name*="addDataBackByLcbm"]').click(function () {
                    p.addDataBack($(this).attr('con').replaceAll('and', '&').replaceAll('\'', '').replaceAll(' ', ''));
                    if (!isIE8) {
                        swal.close();
                    }
                });
            }
        });

    },
    /**
     * 保存数据
     * @param el 保存按钮 | 不可为空 | 示例 this
     */
    saveData: function (el, url, isAlert, isvalidate) {
        if (isvalidate == null) {
            isvalidate = false;
        }
        var form_element = $(el).parents('.form-horizontal');
        if (isvalidate || form_element.validationEngine('validate')) {
            //暂时禁止按钮点击事件
            tool.setWaitForResponseStatus($(el));
            //如果form中没有action
            if (isBlank(form_element.attr("action"))) {
                if (isBlank(form_element.attr("action"))) {
                    url = form_element.attr("data-action");
                    //spring mvc
                    if (url.indexOf("action") < 0) {
                        url = url.substring(0, url.indexOf('/s/') + 7) + url.substring(url.indexOf('/s/') + 7).substring(0, url.substring(url.indexOf('/s/') + 7).indexOf("/"));
                        url = url + "/save";
                    } else {
                        url = url.substr(0, url.indexOf("-")) + "-saveData.action";
                    }
                    //form_element.attr("action", url);
                } else {
                    url = form_element.attr("action");
                }
            }
            var backdrop = $('.ajax-white-backdrop');
            $(".main-container").append('<div class="ajax-white-backdrop"></div>');
            backdrop.show();

            //var alert_element = form_element.find(".alert");
            //if (alert_element.length == 0) {
            //	var button_top = tool.getTop(el);
            //	if(button_top>100) button_top = button_top-100;
            //    $(form_element.find(":first-child")[0]).before("<div class=\"alert dn\" style=\"position:absolute;top:"+button_top+"px;width:90%;z-index:999;\"><button data-dismiss=\"alert\" class=\"close\">×</button><strong></strong></div>");
            //    alert_element = form_element.find(".alert");
            //}else{
            //	var button_top = tool.getTop(el);
            //	if(button_top>100) button_top = button_top-100;
            //	form_element.find(".alert").css({'position':'absolute','top':button_top+'px','width':'90%','z-index':'999'});
            //}

            $.ajax({
                url: tool.initParams(url),
                type: "POST",
                data: form_element.serialize(),
                dataType: "json",
                timeout: 1000 * 30,
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    tool.removeWaitForResponseStatus();
                    backdrop.remove();
                    if (textStatus == "timeout") {
                        tool.alertWarning('请求超时!', '请稍后重试!');
                    } else {
                        tool.alertError(XMLHttpRequest.responseText);
                    }
                },
                success: function (data) {
                    tool.removeWaitForResponseStatus();
                    backdrop.remove();
                    form_element.find("#is_change").val("0");
                    //noinspection JSUnresolvedVariable
                    //alert_element.find("strong").html(data.oper_msg);
                    if (data.oper_res) {
                        tool.alertSuccess(data.oper_msg);
                    } else {
                        tool.alertError(data.oper_msg);
                    }
                    //noinspection JSUnresolvedVariable
                    //alert_element.removeClass("dn alert-success alert-info alert-warning alert-danger").addClass("alert-" + data.oper_res + " bounce animated").one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function () {
                    //    $(this).removeClass("bounce");
                    //});
                    //如果表单中有 wid 元素 并且 data 对象中有wid属性
                    if (!isBlank(data.data)) {
                        if ("wid" in data.data && form_element.find("#wid").length != 0) {
                            form_element.find("#wid").val(data.data.wid);
                        }
                        if ("id" in data.data && form_element.find("#id").length != 0) {
                            form_element.find("#id").val(data.data.id);
                        }
                    }
                    try {
                        subPage.save_callback(data, form_element);
                    } catch (ex) {
                    }
                }
            });
        }
    },
    getTop: function (e) {
        var offset = e.offsetTop;
        if (e.offsetParent != null) offset += tool.getTop(e.offsetParent);
        return offset;
    },
    /**
     * 根据当前form生成子窗口容器ID,并打开窗口
     * @param el form 表单内对象 | 不可为空
     * @param url url | 不可为空
     * @param check_issave 关闭页面时是否检测已经保存 | 可为空 | 默认不检测
     * @param need_res 关闭打开页面后是否刷新本页面 | 可为空 默认不刷新
     */
    openSubviewByForm: function (el, url, check_issave, need_res) {
        var form_element = $(el).parents('.form-horizontal');
        var subview_box = tool.initSubViewBox(form_element);
        if (need_res) {
            tool.res_form = form_element;
        } else {
            tool.res_form = null;
        }
        tool.openSubview(url, subview_box, check_issave);
    },
    alertLogin: function (info) {
        if (info == null) {
            info = '由于您长时间未进行操作,您的登录信息已过期';
        }
        swal({
            title: '重新登录',
            text: info,
            type: "error"
        }, function () {
        	logOut();
        });
    },
    alert: function (obj) {
        swal(obj);
    },
    alertInfo: function (txt, sub_txt) {
        swal(txt, sub_txt, "info");
    },
    alertSuccess: function (txt, sub_txt) {
        swal(txt, sub_txt, "success");
    },
    alertSuccess_lc: function (txt, sub_txt, p) {
        swal({
                title: txt, text: sub_txt, type: "success",
                closeOnConfirm: true,
                closeOnCancel: false
            }, function () {
                if (isFunction(p.lc_callback)) {
                    p.lc_callback();
                }
            }
        );

    },
    alertError: function (txt, sub_txt) {
        swal(txt, sub_txt, "error");
    },
    alertWarning: function (txt, sub_txt) {
        swal(txt, sub_txt, "warning");
    },
    alertConfirm: function (txt, sub_txt, callback,callback2) {
        var cancelText = "";
        var okText = "";
        try {
            if (cookielang != "" && cookielang != null) {
                if (cookielang == "zh") {
                    cancelText = "取消";
                    okText = "确定";
                }
                if (cookielang == "en") {
                    cancelText = "Cancel";
                    okText = "OK";
                }
            } else {
                cancelText = "取消";
                okText = "确定";
            }
        } catch (e) {
            // TODO: handle exception
            cancelText = "取消";
            okText = "确定";
        }

        swal({
            title: txt,
            text: sub_txt,
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: okText,
            cancelButtonText: cancelText,
            closeOnConfirm: false
        }, function (isConfirm) {
            if (!isIE8) {
                swal.close();
            }
            if (isConfirm) {
                callback();
            }else{
            	if(callback2!=null&&callback2!=""){
            		callback2();
            	}
            }
        });
    },
    /**
     * 打开子窗口
     * @param url url | 不可为空
     * @param element_id 子窗口容器 | 不可为空
     * @param check_issave 关闭页面时是否检测已经保存 | 可为空 | 默认不检测
     */
    openSubview: function (url, element_id, check_issave) {
        if (isBlank(check_issave)) {
            check_issave = false;
        }
        var $subView = $("#" + element_id);
        $.ajax({
            type: "get",
            cache: false,
            url: tool.initParams(url),
            dataType: "html",
            success: function (data) {
                tool.removeWaitForResponseStatus();
                $subView.find('div').html(data);
                //try {
                //subPage.ready($subView);
                //}catch (ex){
                //    if (tool.isDebug()) {
                //        throw new Error('js方法 - subPage.ready , error!');
                //    }
                //}
                if (url.indexOf("action") < 0) {//spring mvc
                    $subView.find('.form-horizontal').find("#yspager_currentPageno").attr("name", "currentPageno");
                    $subView.find('.form-horizontal').find("#eachPageRows").attr("name", "eachPageRows");
                }
                if (isBlank($subView.find('.form-horizontal').attr("data-action"))) {
                    $subView.find('.form-horizontal').attr("data-action", url)
                }
                Main.initElement();
                if (check_issave) {
                    $subView.find('.form-horizontal').find("input,textarea,select").change(function () {
                        $subView.find('.form-horizontal').find("#is_change").val("1");
                    });
                }
                $.subview({
                    content: "#" + element_id,
                    onClose: function () {
                        if (check_issave) {
                            if ($subView.find('.form-horizontal').find("#is_change").val() == "1") {
                                bootbox.confirm("您有修改的数据尚未保存,确定要关闭吗?", function (result) {
                                    if (result) {
                                        $.hideSubview();
                                        try {
                                            $('#' + element_id).remove();
                                            subPage.closeCallback();
                                        } catch (ex) {
                                            if (tool.isDebug()) {
                                                throw new Error('js方法 - subPage.closeCallback , error!');
                                            }
                                        }
                                        $subView.remove();
                                    }
                                });
                                return;
                            }
                        }
                        $.hideSubview();
                        try {
                            $('#' + element_id).remove();
                            subPage.closeCallback();
                        } catch (ex) {
                            if (tool.isDebug()) {
                                console.log('js方法 - subPage.closeCallback , not found!');
                            }
                        }
                        //$subView.remove();
                        if (!isBlank(tool.res_form)) {
                            tool.submitForm(tool.res_form);
                        }
                    }
                });
                $subView.find('.form-horizontal').validationEngine({
                    showOneMessage: true
                });
            },
            error: function (xhr, ajaxOptions, thrownError) {
                tool.removeWaitForResponseStatus();
                $subView.html('<h4>无法加载请求的内容' + url + '</h4>').addClass("shake");
            }
        });
    },

    /**
     * 删除数据
     * @param el list删除按钮 | 不可为空
     */
    doRemove: function (el) {
        var form_element = $(el).parents('.form-horizontal');
        var ids = tool.getChoseData(form_element);
        if (!isBlank(ids)) {
            tool.alertConfirm('确定要删除勾选的数据吗?', '删除后将无法恢复，请谨慎操作！', function () {
                tool.setWaitForResponseStatus($(el));
                tool.deleteData(form_element, {"wid": ids});
            })
        } else {
            tool.alertWarning('请选择要删除的数据!', '请在下方列表中勾选要删除的数据');
        }
    },
    /**
     * 根据id删除数据
     * @param el 删除按钮 | 不可为空 | 示例 this
     * @param id 要删除数据的id
     */
    deleteDataById: function (el, id) {
        tool.deleteData($(el).parents('.form-horizontal'), {"wid": id});
    },
    /**
     * 删除数据
     * @param $form 表单对象 | 不可为空
     * @param ajax_data 参数 | 不可为空 | 示例 字符串或者json
     */
    deleteData: function ($form, ajax_data) {
        var url = $form.attr("data-action");
        if (url.indexOf("action") < 0) {
            url = url.substr(0, url.lastIndexOf("/")) + "/remove";
        } else {
            url = url.substr(0, url.indexOf("-")) + "-deleteData.action";
        }
        $.ajax({
            url: tool.initParams(url),
            type: "post",
            data: ajax_data,
            dataType: "json",
            timeout: 1000 * 5,
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                tool.removeWaitForResponseStatus();
                tool.alertWarning('操作失败,请重试!');
            },
            success: function (data) {
                tool.removeWaitForResponseStatus();
                data = eval(data);
                if (data.oper_res) {
                    var $delTr = $("#tr_" + ajax_data.wid.replace(/,/g, ',#tr_'));
                    $delTr.find(".btn").css("border-color", "#fff");
                    $delTr.addClass("isdelete").find("td").css({"background-color": "#FF3300"}).fadeOut(1000, function () {
                        $(this).remove();
                    });
                } else {
                    setTimeout('tool.alertError("' + data.oper_msg + '")', 100);
                }
            }
        });
    },
    /**
     * 查询
     * @param el 查询按钮
     */
    doSearch: function (el) {
        tool.submitForm($(el).parents('.form-horizontal'));
    },
    /**
     * 初始化表格排序
     * 注: 需要排序的表格中请在class上添加table-order
     */
    initOrderTables: function () {
        $(".table-order").each(function () {
            tool.initOrderTable($(this));
        });
    },
    /**
     * 初始化表格排序功能
     * @param $table 表格对象
     */
    initOrderTable: function ($table) {
        $table.find("thead tr th[data-order-name]").each(function () {
            if ($(this).attr("data-is-init") == "1") {

            } else {
                $(this).attr("data-is-init", "1");
                $(this).addClass("poi");
                $(this).append("<i class='fa fa-sort r gray'></i>");
                $(this).off("click").click(function () {
                    var order_type = $(this).attr("data-order-type");
                    var order_icon;
                    if (isBlank(order_type)) {
                        order_icon = "<i class=\"fa fa-sort-desc fa-stack-1x\"></i><i class=\"fa fa-sort-asc fa-stack-1x gray\"></i>";
                        order_type = "desc";
                    }
                    if (order_type == "asc") {
                        order_icon = "<i class=\"fa fa-sort-desc fa-stack-1x gray\"></i><i class=\"fa fa-sort-asc fa-stack-1x black\"></i>";
                        order_type = "desc";
                    } else if (order_type == "desc") {
                        order_icon = "<i class=\"fa fa-sort-desc fa-stack-1x black\"></i><i class=\"fa fa-sort-asc fa-stack-1x gray\"></i>";
                        order_type = "asc";
                    }
                    //重置所有排序
                    $(this).parents("tr").find("th[data-order-name]").each(function () {
                        $(this).removeAttr("data-order-type").find("span,i").remove();
                        $(this).append("<i class='fa fa-sort r gray'></i>");
                    });
                    $(this).attr("data-order-type", order_type).find("span,i").remove();
                    $(this).attr("data-order-type", order_type).append("<span class=\"fa-stack order-icon\">" + order_icon + "</span>");
                    var form_element = $(this).parents('.form-horizontal');
                    form_element.find("#orderField").val($(this).attr("data-order-name"));
                    form_element.find("#orderType").val(order_type);
                    tool.submitForm(form_element);
                });
            }
        });
    },
    /**
     * 检查subview容器是否存在,如果不存在则根据当前所在form生成
     * @param $form_element form对象 | 不可为空
     * @param subview_box 子窗口id | 可为空
     * @returns {*} subview_box子窗口id
     */
    initSubViewBox: function ($form_element, subview_box) {
        if (isBlank(subview_box)) {
            var url = $form_element.attr("data-action");
            if (url.indexOf("?") > -1) {
                url = url.substring(url.indexOf(basePath), url.indexOf("?"));
            }
            subview_box = "subview-box-" + url.replace(/\//g, "-").replace(/\./g, "-").replace(/:/g, "-");
        }
        if ($("#" + subview_box).length == 0) {
            $form_element.parent().append("<div id=\"" + subview_box + "\" class=\"no-display subview-box\"><div class=\"col-xs-12\"></div></div>");
        }
        return subview_box;
    },
    /**
     * 新增一行 (可编辑表格)
     * @param el 新增按钮 | 不可为空 | 示例 this
     */
    addRow: function (el) {
        el = $(el).parents('.form-horizontal');
        var frist_row, model_row = el.find('table:first tbody tr:last-child');//使用最后一行作为模板
        if (model_row.length > 0) {//表格中无数据,使用传入格式生成
            frist_row = el.find('table:first tbody tr:eq(0)');
            frist_row.before("<tr name=\"new-row\">" + model_row.html() + "</tr>");
        } else {
            el.find('table:first tbody').html('<tr name="new-row">' + el.find('#data-model tbody tr:eq(0)').html() + '</tr>');
        }
        frist_row = el.find('table:first tbody tr:eq(0)');
        var i = 0;
        frist_row.find("td").each(function () {
            var el = $(this);
            if (i > 0) {
                if (el.data("edit") == true) {
                    if (!isBlank(el.data("url"))) {//链接
                        el.find("a").hide();
                        el.append("<input type=\"text\" data-name=\"" + el.data("name") + "\" class=\"form-control\" style=\"width:100%;\"/>");
                    } else if (!isBlank(el.data("table-name"))) {//select
                        el.html("<select data-table-name=\"" + tool.getString(el.data("table-name")) + "\" " +
                            "data-field-id=\"" + tool.getString(el.data("field-id")) + "\" " +
                            "data-field-name=\"" + tool.getString(el.data("field-name")) + "\" " +
                            "data-field-up-id=\"" + tool.getString(el.data("field-up-id")) + "\" " +
                            "data-file-up-val=\"" + tool.getString(el.data("file-up-val")) + "\" " +
                            "data-file-query=\"" + tool.getString(el.data("file-query")) + "\" " +
                            "data-query-val=\"" + tool.getString(el.data("query-val")) + "\" " +
                            "data-name=\"" + el.data("name") + "\" " +
                            "style=\"width:100%;\"" +
                            "class=\"form-control select2-auto\"></select>");
                    } else if (el.data("element-type") == "datepicker") {
                        el.html("<input type=\"text\" data-name=\"" + el.data("name") + "\" class=\"form-control\" data-element-type=\"datepicker\" style=\"width:100%;\"/>");
                    } else {
                        el.html("<input type=\"text\" data-name=\"" + el.data("name") + "\" class=\"form-control\" style=\"width:100%;\"/>");
                    }
                }
            } else {
                el.html("");
            }
            i++;
        });
        //绑定事件
        frist_row.find(".edit-row").off("click").click(function () {
            tool.edit_row($(this));
        });
        frist_row.find(".save-row").off("click").click(function () {
            tool.save_row($(this));
        });
        frist_row.find(".del-row").off("click").click(function () {
            tool.del_row($(this));
        });

        //初始化插件
        frist_row.find(".edit-row").addClass("dn").parents("tr").find(".save-row").removeClass("dn");
        Main.initForm(frist_row);
    },
    /**
     * 初始化编辑按钮(for可编辑表格)
     */
    initEditRow: function () {
        var $editRow = $(".edit-row");
        if ($editRow.length) {
            $editRow.each(function () {
                $(this).off("click").click(function () {
                    tool.edit_row($(this));
                });
            });
        }
    },
    /**
     * 初始化保存按钮(for可编辑表格)
     */
    initSaveRow: function () {
        var $saveRow = $(".save-row");
        if ($saveRow.length) {
            $saveRow.each(function () {
                $(this).off("click").click(function () {
                    tool.save_row($(this));
                });
            });
        }
    },
    /**
     * 初始化删除按钮(for可编辑表格)
     */
    initDelRow: function () {
        var $delRow = $(".del-row");
        if ($delRow.length) {
            $delRow.each(function () {
                $(this).off("click").click(function () {
                    tool.del_row($(this));
                });
            });
        }
    },
    /**
     * 保存 (for 可编辑表格)
     * @param el
     */
    save_row: function (el) {
        el = el.parents("tr");
        var url = "";
        var form_element = el.parents('.form-horizontal');
        if (el.validationEngine('validate')) {
            url = form_element.attr("data-action");
            //spring mvc
            if (url.indexOf("action") < 0) {
                url = url.substring(0, url.indexOf('/s/') + 7) + url.substring(url.indexOf('/s/') + 7).substring(0, url.substring(url.indexOf('/s/') + 7).indexOf("/"));
                url = url + "/save";
            } else {
                url = url.substr(0, url.indexOf("-")) + "-saveData.action";
            }
            var backdrop = $('.ajax-white-backdrop');
            $(".main-container").append('<div class="ajax-white-backdrop"></div>');
            backdrop.show();
            el.find("input,select").each(function () {
                $(this).attr("name", $(this).data("name"));
            });
            var data;
            if (el.find("input[name='wid']:checked").length != 0) {//如果选中
                data = el.find("input,select").serialize();
            } else {
                if (el.find("input[name='wid']").length > 0) {//修改
                    data = el.find("input,select").serialize() + "&wid=" + el.find("input[name='wid']").val();
                } else {
                    data = el.find("input,select").serialize();
                }
            }
            $.ajax({
                url: tool.initParams(url),
                type: "POST",
                data: data,
                dataType: "json",
                timeout: 1000 * 10,
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    backdrop.remove();
                    if (textStatus == "timeout") {
                        tool.alertWarning('请求超时!', '请稍后重试!');
                    } else {
                        tool.alertWarning(XMLHttpRequest.responseText);
                    }
                },
                success: function (data) {
                    el.find(".save-row").addClass("dn").parents("tr").find(".edit-row").removeClass("dn");
                    if (!isBlank(data)) {
                        //noinspection JSUnresolvedVariable
                        if (data.oper_res == "success") {//成功
                            //如果tr[id]为空 则表示新增
                            if (el.attr("name") == "new-row") {//新增
                                el.attr("id", "tr_" + data.data.wid);
                                el.find("td:eq(0)").html("<div class=\"checkbox-table\"><label><input data-name=\"wid\" type=\"checkbox\" name=\"selectNode\" class=\"grey foocheck\" id=\"" + data.data.wid + "\" value=\"" + data.data.wid + "\"></label></div>");
                                el.removeAttr("name");
                                el.find(".del-row").attr("data-wid", data.data.wid);
                                Main.initForm(el);
                            }
                            el.find("td").each(function () {
                                if (!isBlank($(this).attr("data-name")) && $(this).attr("data-name") != "wid") {
                                    if (!isBlank($(this).data("url"))) {//链接
                                        //a连接 默认使用修改方法
                                        $(this).html("<a onclick=\"editDataById(this,'" + data.data.wid + "')\" href=\"javascript:void(0)\">" + $(this).find("input").val() + "</a>");
                                    } else {
                                        if ($(this).find("input").length > 0) {
                                            $(this).html($(this).find("input").val());
                                        } else if ($(this).find("select").length > 0) {
                                            $(this).html($(this).find("select").find("option:selected").text());
                                        }
                                    }
                                }
                            });
                        } else {
                            tool.alertSuccess(data.open_msg);
                        }
                    }
                    backdrop.remove();
                }
            });
        }
    },
    openloading: function ($el, tit) {
        if (isIE8) {
            if ($el == null || $el == '') $el = $('body');
            if (tit == null || tit == '') tit = '加载中...';
            $el.block({
                overlayCSS: {
                    backgroundColor: '#fff'
                },
                message: '<i class="fa fa-spinner fa-spin"></i>' + tit,
                css: {
                    border: 'none',
                    color: '#333',
                    background: 'none'
                }
            });
        } else {
            if (tit == null || tit == '') {
                tit = '';
            }
            $('#loader-wrapper h2').html(tit);
            $('body').removeClass('loaded');
        }
    },
    closeloading: function ($el) {
        if (isIE8) {
            if ($el == null || $el == '') $el = $('body');
            $el.unblock();
        } else {
            $('body').addClass('loaded');
        }
    },
    /**
     * 删除行(for 可编辑表格)
     * @param el
     */
    del_row: function (el) {
        tool.deleteData(el.parents('.form-horizontal'), {"wid": el.data("wid")});
    },
    edit_row: function (el_btn) {
        $(el_btn.parents("tr").find("td")).each(function () {
            var el = $(this);
            if (el.data("edit") == true) {
                if (!isBlank(el.data("url"))) {//链接
                    el.find("a").hide();
                    el.append("<input type=\"text\" data-name=\"" + el.data("name") + "\" class=\"form-control\" value=\"" + trim(el.find("a").html()) + "\" style=\"width:100%;\"/>");
                } else if (!isBlank(el.data("table-name"))) {//select
                    el.html("<select data-table-name=\"" + tool.getString(el.data("table-name")) + "\" " +
                        "data-field-id=\"" + tool.getString(el.data("field-id")) + "\" " +
                        "data-field-name=\"" + tool.getString(el.data("field-name")) + "\" " +
                        "data-field-up-id=\"" + tool.getString(el.data("field-up-id")) + "\" " +
                        "data-file-up-val=\"" + tool.getString(el.data("file-up-val")) + "\" " +
                        "data-file-query=\"" + tool.getString(el.data("file-query")) + "\" " +
                        "data-query-val=\"" + tool.getString(el.data("query-val")) + "\" " +
                        "data-name=\"" + el.data("name") + "\" " +
                        "data-val=\"" + tool.getString(el.data("val")) + "\" style=\"width:100%;\"" +
                        "class=\"form-control select2-auto\"></select>");
                } else if (el.data("element-type") == "datepicker") {
                    el.html("<input type=\"text\" data-name=\"" + el.data("name") + "\" class=\"form-control\" data-element-type=\"datepicker\" value=\"" + trim(el.html()) + "\" style=\"width:100%;\"/>");
                } else {
                    el.html("<input type=\"text\" data-name=\"" + el.data("name") + "\" class=\"form-control\" value=\"" + trim(el.html()) + "\" style=\"width:100%;\"/>");
                }
            }
        });
        el_btn.addClass("dn").parents("tr").find(".save-row").removeClass("dn");
        Main.initForm(el_btn.parents("tr"));

    },
    /**
     * 检查浏览器是否支持html5上传
     * @returns {boolean}
     */
    supportHtml5: function () {
        if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) {
            var ieversion = new Number(RegExp.$1);
            if (ieversion == 8 || ieversion == 9) {
                isIE8 = true;
                return false
            } else {
                return true;
            }
        } else {
            return true;
        }
    },

    /**
     * 触发开始上传
     * @param $el
     */
    startUpload: function ($el) {
        if (!tool.supportHtml5()) {//IE8/9不支持html5方式上传,需要用flash
            $el.uploadify('upload', '*');
        } else {
            $el.uploadifive('upload');
        }
    },
    has_flash: function () {
        var isIE = !-[1,];
        if (isIE) {
            try {
                return !!new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
            }
            catch (e) {
            }
        } else {
            try {
                return !!navigator.plugins['Shockwave Flash'];
            }
            catch (e) {
            }
        }
        return false;
    },
    /**
     * 初始化文件上传
     * @param el file element
     * @param url url
     * @param data 附加数据
     * @param auto 是否自动上传
     * @param fileTypeExts 支持的格式
     * @param queueSizeLimit 上传文件数量限制
     * @param onSelect 选择文件事件
     * @param onUploadSuccess 文件上传成功事件
     * @param onQueueComplete 列队所有文件上传完毕
     * @param fileSizeLimit 上传文件大小限制
     * @param uploadfileQueue 上传列队显示容器
     * @param buttonText 上传按钮文字
     * @param onUploadStart 文件开始上传
     */
    initFileUpload: function (el, url, data, auto, fileTypeExts, queueSizeLimit, onSelect, onUploadSuccess,
                              onQueueComplete, fileSizeLimit, uploadfileQueue, buttonText, onUploadStart, buttonClass) {
        var config = {};
        config.auto = auto;
        if (isBlank(fileSizeLimit)) {
            config.fileSizeLimit = '20MB';
        } else {
            config.fileSizeLimit = fileSizeLimit;
        }
        if (!isBlank(uploadfileQueue)) {
            config.queueID = uploadfileQueue;
        }
        if (isBlank(buttonClass)) {
            config.buttonClass = 'btn btn-sm btn-info';
        } else {
            config.buttonClass = buttonClass;
        }
        if (isBlank(buttonText)) {
            config.buttonText = '选择文件 <i class=\"fa fa-plus\"></i>';
        } else {
            config.buttonText = buttonText;
        }
        config.selector = el;
        config.formData = data;
        config.onSelect = onSelect;
        config.onQueueComplete = onQueueComplete;
        config.removeCompleted = true;
        if (!tool.supportHtml5()) {//IE8/9不支持html5方式上传,需要用flash
            config.onUploadStart = onUploadStart;
            config.onUploadSuccess = onUploadSuccess;
            config.onUploadError = function (file, errorCode, errorMsg, errorString) {
                try {
                    subPage.onUploadError();
                } catch (ex) {
                }
            }
            config.onInit = function () {
                if (!tool.has_flash()) {
                    swal({
                        title: "缺少Flash插件",
                        type: 'warning',
                        text: "您未安装Flash控件，无法上传文件！请使用Chrome/Firefox/IE10+浏览器，或<a target='_blank' href='https://get.adobe.com/flashplayer/?loc=cn'>点此</a>安装FLASH控件重启浏览器后重试。",
                        html: true,
                        showConfirmButton: false
                    });
                }
            }
            if (isBlank(url)) {
                config.uploader = basePath + "/fileUpload";
            } else {
                config.uploader = url;
            }
            config.fileTypeDesc = '支持的格式：';
            config.fileTypeExts = fileTypeExts;
            config.width = 82;
            config.height = 30;
            config.swf = basePath + '/resources/plugins/uploadify/uploadify.swf';
            config.onSelectError = function (file, errorCode, errorMsg) {
                switch (errorCode) {
                    case -100:
                        tool.alertWarning("上传的文件数量已经超出系统限制！");
                        break;
                    case -110:
                        tool.alertWarning("文件大小超出系统限制的" + fileSizeLimit + "！");
                        break;
                    case -120:
                        tool.alertWarning("文件大小异常！");
                        break;
                    case -130:
                        tool.alertWarning("文件类型不正确！");
                        break;
                }
            }
            config.onFallback = function () {
                swal({
                    title: "缺少Flash插件",
                    type: 'warning',
                    text: "您未安装Flash控件，无法上传文件！请使用Chrome/Firefox/IE10+浏览器，或<a target='_blank' href='https://get.adobe.com/flashplayer/?loc=cn'>点此</a>安装FLASH控件重启浏览器后重试。",
                    html: true,
                    showConfirmButton: false
                });
            }
            try {
                if (!isBlank(config.selector)) {
                    $(config.selector).uploadify(config);
                }
            } catch (e) {
                console.log(e);
            }
        } else {
            //即将上传
            config.onUpload = onUploadStart;
            //上传完毕
            config.onUploadComplete = onUploadSuccess;
            if (isBlank(url)) {
                config.uploadScript = basePath + "/fileUpload";
            } else {
                config.uploadScript = url;
            }
            if (isNotBlank(fileTypeExts)) {
                fileTypeExts = tool.extensionToContentTypes(fileTypeExts);
            }
            config.fileType = fileTypeExts;
            config.onFallback = function () {
            }
            try {
                if (!isBlank(config.selector)) {
                    $(config.selector).uploadifive(config);
                }
            } catch (e) {
                console.log(e);
            }
        }
    },
    /**
     * 初始化文件上传
     * @param object
     */
    initFileUploadByConfig: function (object) {
        //按钮样式
        if (isBlank(object.buttonClass)) {
            object.buttonClass = 'btn btn-sm btn-info';
        }
        //按钮文字
        if (isBlank(object.buttonText)) {
            object.buttonText = '选择文件 <i class=\"fa fa-plus\"></i>';
        }
        //大小限制
        if (isBlank(object.fileSizeLimit)) {
            object.fileSizeLimit = '20MB';
        }
        object.removeCompleted = true;
        //是否自动上传
        if (isBlank(object.auto)) object.auto_upload = false;
        if (!tool.supportHtml5()) {//IE8/9不支持html5方式上传,需要用flash
            if (isBlank(object.uploader)) object.uploader = basePath + "/fileUpload";
            object.swf = basePath + '/resources/plugins/uploadify/uploadify.swf';
            if (isBlank(object.fileTypeDesc)) {
                object.fileTypeDesc = '支持的格式：';
            }
            if (isBlank(object.onSelectError)) {
                object.onSelectError = function (file, errorCode, errorMsg) {
                    switch (errorCode) {
                        case -100:
                            tool.alertWarning("上传的文件数量已经超出系统限制！");
                            break;
                        case -110:
                            tool.alertWarning("文件大小超出系统限制的" + fileSizeLimit + "！");
                            break;
                        case -120:
                            tool.alertWarning("文件大小异常！");
                            break;
                        case -130:
                            tool.alertWarning("文件类型不正确！");
                            break;
                    }
                }
            }
            if (isBlank(object.onFallback)) {
                object.onFallback = function () {
                    swal({
                        title: "缺少Flash插件",
                        type: 'warning',
                        text: "您未安装Flash控件，无法上传文件！请使用Chrome/Firefox/IE10+浏览器，或<a target='_blank' href='https://get.adobe.com/flashplayer/?loc=cn'>点此</a>安装FLASH控件重启浏览器后重试。",
                        html: true,
                        showConfirmButton: false
                    });
                }
            }
            try {
                if (!isBlank(object.selector)) {
                    $(object.selector).uploadify(object);
                }
            } catch (e) {
                console.log(e);
            }
        } else {
            //服务器处理url
            if (isBlank(object.uploader)) {
                object.uploadScript = basePath + "/fileUpload";
            } else {
                object.uploadScript = object.uploader;
            }
            //即将上传
            object.onUpload = object.onUploadStart;
            //上传完毕
            object.onUploadComplete = object.onUploadSuccess;
            if (isNotBlank(object.fileTypeExts)) {
                object.fileType = tool.extensionToContentTypes(object.fileTypeExts);
            }
            if (isBlank(object.onFallback)) {
                object.onFallback = function () {
                    // tool.alertWarning("您未安装FLASH控件，无法上传文件！请安装FLASH控件后再试。");
                }
            }

            try {
                if (!isBlank(object.selector)) {
                    $(object.selector).uploadifive(object);
                }
            } catch (e) {
                console.log(e);
            }
        }
    },
    /**
     * 文件拓展名(Extension)转Content-Type(Mime-Type)
     * @param extensions
     */
    extensionToContentTypes: function (extensions) {
        extensions = extensions.split(';');
        var contentType = [];
        var temp = null;
        for (var i = 0; i < extensions.length; i++) {
            temp = CONTENT_TYPE[extensions[i].replace('*', '')];
            if (isNotBlank(temp)) {
                contentType.push(temp);
            }
        }
        return contentType;
    },
    /**
     * 文件拓展名(Extension)转Content-Type(Mime-Type)
     * @param extension
     */
    extensionToContentType: function (extension) {
        return CONTENT_TYPE[extension];
    },

    /**
     * 打开modal窗口
     * @param options
     * @returns {*|jQuery|HTMLElement}
     */
    openModal: function (options, width, isiframe, callback, height) {
        if (height == null || height == '') {
            height = $('.J_mainContent', window.parent.document).height() - 170;
        }
        if (width == "" || width == null) {
            width = "";
        }
        if (options.remote.indexOf('jd=') == -1) {
            options.remote = tool.initParams(options.remote);
        }
        var modal_id = tool.randomString(15);
        if (isiframe == null || isiframe) {
            var iframeid = tool.randomString(15);
            var html = '<div class="modal fade" id="' + modal_id + '" tabindex="-1" role="dialog" aria-hidden="true">' +
                '<div class="modal-dialog modal-lg" style="width:' + width + '">' +
                '<div class="modal-content">' +
                '<div class="modal-body">';
            html += '<iframe id="' + iframeid + '" width="100%" height="' + height + '" frameborder="0" src="' + options.remote + '"></iframe>';
            html += '</div></div></div>';
            $('body').append(html);
            var $modal = $('#' + modal_id);
            $modal.modal({backdrop: 'static',keyboard:false}).modal('show').on('shown.bs.modal', function (e) {
                Main.initTabModel($modal)
                $modal.removeAttr('tabindex');
            }).on('hidden.bs.modal', function (e) {
                // 关闭时销毁
                $modal.remove();
            });

        } else {
            var html = '<div class="modal fade" id="' + modal_id + '" tabindex="-1" role="dialog" aria-hidden="true">' +
                '<div class="modal-dialog modal-lg" style="width:' + width + '">' +
                '<div class="modal-content" style="display: table;width: 100%;">';
            $.ajax({
                url: options.remote,
                cache: false,
                type: "post",
                dataType: "html",
                timeout: 1000 * 15,
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    tool.ajaxError(XMLHttpRequest, textStatus, errorThrown);
                },
                success: function (data) {
                    var $data = $(data);
                    //将本页面url放到form的data-action中
                    if ($data.find(".form-horizontal").length > 0) {
                        if (isBlank($data.find(".form-horizontal").attr("data-action"))) {
                            $data.find(".form-horizontal").attr("data-action", options.remote);
                        }
                        if (options.remote.indexOf("action") < 0) {//spring mvc
                            $data.find(".form-horizontal").find("#yspager_currentPageno").attr("name", "currentPageno");
                            $data.find(".form-horizontal").find("#eachPageRows").attr("name", "eachPageRows");
                        }
                    } else {
                        data = '<div><form class="form-horizontal" data-action="' + options.remote + '">' + data + '</form></div>';
                        $data = $(data);
                    }
                    if ($data.find('.modal-header').length <= 0) {
                        html += '<div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button><h4 class="modal-title">&nbsp;</h4></div>'
                    }
                    if ($data.find('.modal-body').length <= 0) {
                        html += '<div class="modal-body">' + $data.find('.form-horizontal').prop('outerHTML') + '</div>';
                    } else {
                        html += $data.find('.form-horizontal').prop('outerHTML');
                    }
                    // if ($data.find('.modal-footer').length <= 0) {
                    // html += '<div class="modal-footer"><button type="button" class="btn btn-default btn-sm" data-dismiss="modal">关闭</button></div>';
                    // }
                    html += '</div></div></div>'
                    $('body').append(html);
                    var $modal = $('#' + modal_id);
                    $modal.modal('show').on('shown.bs.modal', function (e) {
                        Main.initTabModel($modal);
                        $modal.removeAttr('tabindex');
                    }).on('hidden.bs.modal', function (e) {
                        // 关闭时销毁
                        $modal.remove();
                    });
                    if (isFunction(callback)) {
                        callback();
                    }
                }
            });
        }
        return modal_id;
    },
    modal: function ($el, options, show, shown, hide, hidden) {
        $el.modal(options);
        $el.on('show.bs.modal', show);
        $el.on('shown.bs.modal', shown);
        $el.on('hide.bs.modal', hide);
        $el.on('hidden.bs.modal', hidden);
    },
    /**
     * 随即产生指定长度字符串
     * @param len
     * @returns {string}
     */
    randomString: function (len) {
        len = len || 32;
        var $chars = 'ABCDEFGHJKMINOPQRSTUVWXYZabcdefhijkminopqrstuwxyz';
        var maxPos = $chars.length;
        var pwd = '';
        for (var i = 0; i < len; i++) {
            pwd += $chars.charAt(Math.floor(Math.random() * maxPos));
        }
        return pwd;
    },
    /**
     * 获取字符串,如果是undefined 返回 ""
     * @param str
     * @returns {*}
     */
    getString: function (str) {
        if (isBlank(str)) {
            str = "";
        }
        return str;
    },
//兼容上个框架方法
    /**
     * 保存
     * @param el form中的一个对象 (this)
     */
    submit_save: function (el) {
        tool.saveData(el);
    },
    /**
     * 查询
     * @param el form中的一个对象 (this)
     */
    super_doSearch: function (el) {
        tool.doSearch(el);
    },
    /**
     * 修改
     * @param el form中的一个对象 (this)
     */
    doModify: function (el) {
        tool.editData(el);
    },
    /**
     * 打开窗口
     * @param el form中的一个对象 (this)
     * @param url url
     */
    openview: function (el, url) {
        var form_element = $(el).parents('.form-horizontal');
        var subview_box = tool.initSubViewBox(form_element);
        tool.res_form = form_element;
        tool.openSubview(url, subview_box, false);
    },

    openEntity: function (el, id) {
        tool.editDataById(el, id);
    },
    /**
     * 重置
     * @param el form中的一个对象 (this)
     */
    super_reset: function (el) {
        tool.resetForm(el);
    },
    /**
     * 下载文件
     * @param path
     */
    downloadfile: function (path) {
        $('#iframedownload').attr('src', basePath + '/filedownload.jsp?path=' + path.replaceAll('\\\\', '\/'));
    },
    /**
     * 加密url，返回带加密串的新url
     * @param url
     * @returns {*}
     */
    initParams: function (url) {
        // $.ajax({
        //     type: "post",
        //     url: basePath + '/s/geturl',
        //     data: "url="  + url.replaceAll('&','jdand') +  "&userloginid=" + tool.userloginid,
        //     async: false,
        //     error: function (XMLHttpRequest, textStatus, errorThrown) {
        //         if (textStatus == "timeout") {
        //             tool.alertWarning('请求超时!', '请稍后重试!');
        //         } else {
        //             tool.alertError(XMLHttpRequest.responseText);
        //         }
        //     },
        //     success: function (data) {
        //         if (url.indexOf('?') != -1) {
        //             url = url + '&jddes=' + data;
        //         } else {
        //             url = url + '?jddes=' + data;
        //         }
        //     }
        // });
        return url;
    },
    /**
     * 设置按钮为等待ajax响应状态,并禁止点击事件
     * @param $el 按钮 | jquery对象
     */
    setWaitForResponseStatus: function ($el) {
        tool.waitForResponseStatusBtn = $el;
        $el.attr('disabled', 'disabled').attr('data-text', $el.html()).html('<i class="fa fa-circle-o-notch fa-spin"></i> 处理中...');
        //if ($el[0].nodeName == "A") {
        //$el.attr('data-click', $el.attr('onclick')).attr('onclick', '');
        //}
        var _i = $el.find('i');
        if (_i.length > 0) {
            _i.attr('data-btn-icon', _i.attr('class'));
            _i.attr('class', 'fa fa-circle-o-notch fa-spin');
        }
    },
    /**
     * 移除按钮等待ajax响应状态,并恢复点击事件
     * @param $el 按钮 | jquery对象
     */
    removeWaitForResponseStatus: function () {
        if (tool.waitForResponseStatusBtn != null && tool.waitForResponseStatusBtn.length > 0) {
            tool.waitForResponseStatusBtn.removeAttr('disabled', 'disabled').html(tool.waitForResponseStatusBtn.attr('data-text'));
            //if (tool.waitForResponseStatusBtn[0].nodeName == "A") {
            //tool.waitForResponseStatusBtn.attr('onclick', tool.waitForResponseStatusBtn.attr('data-click'));
            //}
            var _i = tool.waitForResponseStatusBtn.find('i');
            if (_i.length > 0) {
                _i.attr('class', _i.attr('data-btn-icon'));
            }
            tool.waitForResponseStatusBtn = null;
        }
    },
    /**
     * 显示等待提示
     */
    showWaitTip: function () {
        $('.modal-backdrop, .wait-tip').removeClass('hide');
        //setTimeout('tool.setWaitTip()',2000);
    },
    setWaitTip: function () {
        $('.wait-tip .panel-body').html('<i class="fa fa-circle-o-notch fa-spin"></i> 数据量大,请耐心等待...');
    },
    /**
     * 隐藏等待提示
     */
    hideWaitTip: function () {
        $('.modal-backdrop, .wait-tip').addClass('hide');
        $('.wait-tip .panel-body').html('<i class="fa fa-circle-o-notch fa-spin"></i> 数据加载中,请稍候...');
    },
    isNotEmpty: function (val) {
        return !tool.isEmpty(val);
    },
    isEmpty: function (val) {
        if ((val == null || typeof(val) == "undefined") || (typeof(val) == "string" && val == "" && val != "undefined")) {
            return true;
        } else {
            return false;
        }
    },
    isDebug: function () {
        if (tool.isNotEmpty(tool.configDebug) && tool.configDebug == "true") {
            return true;
        } else {
            return false;
        }
    },
    //去除元素内所有内容 strIds："#id1,#id2,#id3"
    emptyHtml: function (strIds) {
        try {
            var ids = strIds.trim(",").split(",");
            $(ids).each(function () {
                var obj = $(tool.toString());
                if (obj.length > 0) {
                    $(obj).each(function () {
                        $(this).html("");
                    });
                } else {
                    obj.html("");
                }
            });
        } catch (ex) {
            if (tool.isDebug()) {
                throw new Error("js方法 - tool.emptyHtml(strIds),error！");
            }
        }
    },
    //去除元素的值 strIds："#id1,#id2,#id3"
    emptyValue: function (strIds) {
        try {
            var ids = strIds.trim(",").split(",");
            $(ids).each(function () {
                var obj = $(tool.toString());
                if (obj.length > 0) {
                    $(obj).each(function () {
                        $(this).val("");
                    });
                } else {
                    obj.val("");
                }
            });
        } catch (ex) {
            if (tool.isDebug()) {
                throw new Error("js方法 - tool.emptyValue(strIds),error!");
            }
        }
    },
    //去除Textarea内所有内容 strIds："#id1,#id2,#id3"
    emptyTextarea: function (strIds) {
        try {
            var ids = strIds.trim(",").split(",");
            $(ids).each(function () {
                var obj = $(tool.toString());
                if (obj.length > 0) {
                    $(obj).each(function () {
                        $(this).empty();
                        $(this).val("");
                    });
                } else {
                    obj.empty();
                    obj.val("");
                }
            });
        } catch (ex) {
            if (tool.isDebug()) {
                throw new Error("js方法 - tool.emptyTextarea(strIds) ,error！");
            }
        }
    },
    report: function (el, ids, lcbm, type, glzd, con, json, thyj) {
        if (ids == null || ids == '') {
            var form_element = $(el).parents('.form-horizontal');
            var ids = tool.getChoseData(form_element);
            if (ids == null || ids == '') {
                tool.alertConfirm('未选中数据，是否操作所有数据！', '', function () {
                    $.post(tool.initParams(tool.procee + 's/biz/ajaxProcess/handle'), {
                        'handleids': 'allid', 'lcbm': lcbm, 'glzd': glzd, 'thyj': thyj,
                        'type': type, 'json': json, 'con': con
                    }, function (data) {
                        setTimeout('tool.alertSuccess("' + data.jsonstr + '")', 100);
                        tool.submitForm($(el).parents('.form-horizontal'));
                        subPage.lc_callback(el, data);
                    });
                });
                return false;
            }
        }

        $.post(tool.initParams(tool.procee + 's/biz/ajaxProcess/handle'), {
            'handleids': ids, 'lcbm': lcbm, 'glzd': glzd, 'thyj': thyj,
            'type': type, 'json': json, 'con': con
        }, function (data) {
            setTimeout('tool.alertSuccess("' + data.jsonstr + '")', 100);
            tool.submitForm($(el).parents('.form-horizontal'));
            subPage.lc_callback(el, data);
        });
    },
    report_s: function (el, lcbm, type, glzd, con, json, thyj) {
        tool.report(el, null, lcbm, type, glzd, con, json, thyj);
    },
    report_all: function (el, lcbm, type, glzd, con, json, thyj) {
        tool.report(el, 'allid', lcbm, type, glzd, con, json, thyj);
    },
    report_open: function (el, lcbm, type, glzd, con, json, isreq, tool_ch) {
        if (tool_ch == null) tool_ch = tool;
        swal({
                title: "填写审核意见!",
                text: "请在下面输入框中填写意见，之后点击确定按钮完成审核",
                type: "input",
                showCancelButton: true,
                closeOnConfirm: false,
                animation: "slide-from-top",
                inputPlaceholder: "审核意见"
            },
            function (inputValue) {
                if (inputValue === false) return false;
                if (inputValue === "" && isreq) {
                    swal.showInputError("请先填写意见!");
                    return false
                }
                if (json != null) json = json.replace('$thyj', inputValue);
                tool_ch.report(el, null, lcbm, type, glzd, con, json, inputValue);
            }
        );
    },
    report_open_input: function (el, ids, lcbm, type, glzd, con, json, isreq, tool_ch) {
        if (tool_ch == null) tool_ch = tool;
        swal({
                title: "填写审核意见!",
                text: "请在下面输入框中填写意见，之后点击确定按钮完成审核",
                type: "input",
                showCancelButton: true,
                closeOnConfirm: false,
                animation: "slide-from-top",
                inputPlaceholder: "审核意见"
            },
            function (inputValue) {
                if (inputValue === false) return false;
                if (inputValue === "" && isreq) {
                    swal.showInputError("请先填写意见!");
                    return false
                }
                if (json != null) json = json.replace('$thyj', inputValue);
                tool_ch.report(el, ids, lcbm, type, glzd, con, json, inputValue);
            }
        );
    },
    getlog: function (el, lcbm, wid) {
        $.post(tool.initParams(tool.procee + 's/biz/ajaxProcess/getLog'), {
            'lcbm': lcbm, 'wid': wid
        }, function (data) {
            $('#logmodel').remove();
            $('#log_main_btn').remove();
            var htm = '<div class="modal fade" id="logmodel" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" style="width: 90%;left: 5%;">' +
                '<div class="modal-dialog" role="document">' +
                '<div class="modal-content">' +
                '<div class="modal-header">' +
                '<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>' +
                ' <h4 class="modal-title" id="myModalLabel">操作记录</h4>' +
                '</div>' +
                '<div class="modal-body">' +
                data.log +
                '</div>' +
                '<div class="modal-footer">' +
                ' <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>' +
                '</div>' +
                '</div>' +
                ' </div>' +
                '</div><button id="log_main_btn" type="button" class="btn btn-primary" style="display: none;" data-toggle="modal" data-target="#logmodel">' +
                '日志' +
                '</button>';
            $(el).parents('.form-horizontal').append(htm);
            $('#log_main_btn').click();
        });
    },
    getlog_htm: function (lcbm, wid, id) {
        $.post(tool.initParams(tool.procee + 's/biz/ajaxProcess/getLog'), {
            'lcbm': lcbm, 'wid': wid
        }, function (data) {
            $('#id').html(data.log);
        });
    },
    timeout_import: null,
    times_import: 0,
    openimport: function (info) {
        clearTimeout(tool.timeout_import);
        tool.initimport();
        $('#import_times').remove();
        $('#importcontent').find('font').css({'color': '#b1b1b1', 'font-weight': 'normal', 'font-size': '14px'});
        $('#importcontent').find('font:last').append('，用时' + tool.times_import + '秒');
        $('#importcontent').append('<font>' + info + '<span id="import_times"><lable>0</lable>秒</span></font>');
        $('#importcontent').find('font:last').css({'color': '#555555', 'font-weight': 'bold', 'font-size': '14px'});
        $('div[id*="importload"]').css('display', '');
        tool.times_import = 0;
        tool.timeout_import = setTimeout('tool.importtimes()', 1000);

    },
    initimport: function () {
        var h = document.body.scrollHeight;
        if (h < document.documentElement.clientHeight) {
            h = document.documentElement.clientHeight;
        }
        $('#importload_back').css("height", h);
        $('#importload_back').css("width", document.body.scrollWidth);
        $('#importload').css("left", (document.body.scrollWidth - 700) / 2);
        $('#importload').css("top", (h - 400) / 2);
    },
    closeimport: function () {
        $('#importcontent').html('');
        $('div[id*="importload"]').css('display', 'none');
    },
    importtimes: function () {
        tool.times_import++;
        $('#import_times').find('lable').html(tool.times_import);
        tool.timeout_import = setTimeout('tool.importtimes()', 1000);
    },
    initbtnQx: function (form_t, lcbm, nd, xq) {
        $.post(tool.initParams(tool.procee + 's/biz/ajaxProcess/isstart'), {
            'nd': nd,
            'xq': xq,
            'lcbm': lcbm
        }, function (data) {
            if (data.count == '0') {//没开启
                form_t.find('button,a').each(function () {
                    if ($(this).attr('ssyhqx') == '2' || $(this).attr('ssyhqx') == '3') {
                        $(this).remove();
                    }
                });
            }
        });
    },
    initbtnQxBack: function (form_t, lcbm, nd, xq, p) {
        $.post(tool.initParams(tool.procee + 's/biz/ajaxProcess/isstart'), {
            'nd': nd,
            'xq': xq,
            'lcbm': lcbm
        }, function (data) {
            if (data.count == '0') {//没开启
                p.btnBack();
            }
        });
    },
    /**
     * 删除文件
     * @param el this
     * @param path 文件路径
     */
    deleteFileRow: function (el, path) {
        //if (path.indexOf('file_zs') > -1) {
        $.ajax({
            url: basePath + '/s/ajax/deleteFile',
            type: "post",
            data: {
                'path': path
            },
            dataType: "json",
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                tool.alertError('请求超时!', '请稍后重试!');
            },
            success: function (data) {
                if (data.oper_res) {
                    var $delTr = $(el).parents('tr');
                    $delTr.find(".btn").css("border-color", "#fff");
                    $delTr.addClass("isdelete").find("td").css({"background-color": "#FF3300"}).fadeOut(1000, function () {
                        $(this).parents('tr').remove();
                    });
                } else {
                    tool.alertWarning(data.message);
                }
            }
        });
        //} else {
        //    var $delTr = $(el).parents('tr');
        //    $delTr.find(".btn").css("border-color", "#fff");
        //    $delTr.addClass("isdelete").find("td").css({"background-color": "#FF3300"}).fadeOut(1000, function () {
        //        $(this).parents('tr').remove();
        //    });
        //}
    },
    addUploadAttachmentRow: function (data) {
        var index = tool.fileUpload.find('table tbody').find('tr:last').attr('data-index');
        if (index != null && index != '') {
            index = Number(index) + 1;
        } else {
            index = 0;
        }
        var list = tool.fileUpload.find('table').attr('data-list');
        tool.fileUpload.find('table tbody').append('<tr data-index="' + index + '"><td><input name="' + list + '[' + index + '].name" value="' + data.fileold + '" hidden>' +
            '<input name="' + list + '[' + index + '].path" value="' + data.filePath + '" hidden><i class="fa ' + tool.getFileIcon(data.fileold) + '"></i> ' + data.fileold + '</td>' +
            '<td class="tc"><a class="btn btn-xs btn-blue tooltips" data-placement="top" data-original-title="删除" onclick="tool.deleteFileRow(this,\'' + data.filePath + '\')" href="javascript:void(0)"><i class="fa fa-times"></i></a> ' +
            '<a class="btn btn-xs btn-blue tooltips" data-placement="top" data-original-title="下载" onclick="tool.downloadfile(\'' + data.filePath + '\')" href="javascript:void(0)"><i class="fa fa-download"></i></a></td></tr>');
    },
    addUploadImageRow: function (data) {
        var index = tool.fileUpload.find('table tbody').find('tr:last').attr('data-index');
        if (index != null && index != '') {
            index = Number(index) + 1;
        } else {
            index = 0;
        }
        var list = tool.fileUpload.find('table').attr('data-list');
        tool.fileUpload.find('table tbody').append('<tr data-index="' + index + '"><td><input name="' + list + '[' + index + '].name" value="' + data.fileold + '" hidden>' +
            '<input name="' + list + '[' + index + '].path" value="' + data.filePath + '" hidden> <img onclick="tool.previewImage(\'' + data.filePath + '\')" class="thumbnail" src="' + basePath + '/photoshow.jsp?path=' + data.filePath + '"></td>' +
            '<td class="tc"><a class="btn btn-xs btn-blue tooltips" data-placement="top" data-original-title="删除" onclick="tool.deleteFileRow(this,\'' + data.filePath + '\')" href="javascript:void(0)"><i class="fa fa-times"></i></a> ' +
            '<a class="btn btn-xs btn-blue tooltips" data-placement="top" data-original-title="下载" onclick="tool.downloadfile(\'' + data.filePath + '\')" href="javascript:void(0)"><i class="fa fa-download"></i></a></td></tr>');
    },
    previewImage: function (el) {
        if (el == null || el == '') {
            $('.image-preview img').viewer();
        } else {
            $(el).viewer();
        }
    },
    previewImageUrl: function (url) {
        $('.image-preview').attr('src', url).viewer({
            navbar: false
        }).viewer('show');
    },
    initFileIcon: function () {
        $('i[data-file-name]').each(function () {
            $(this).addClass(tool.getFileIcon($(this).attr('data-file-name')))
        });
    },
    /**
     * 根据文件名获取文件字体库图标
     * @param filename
     * @returns {string}
     */
    getFileIcon: function (filename) {
        var temp = filename.substr(filename.indexOf('.') + 1, filename.length);
        temp = temp.toLowerCase();
        if (temp == 'txt') {//文本
            return 'fa-file-text-o';
        } else if (temp == 'zip' || temp == 'rar') {//压缩文件
            return 'fa-file-zip-o';
        } else if (temp == 'mp3' || temp == 'aac' || temp == 'wav' || temp == 'wma' || temp == 'cda' || temp == 'flac' || temp == 'm4a' || temp == 'mid' ||
            temp == 'mka' || temp == 'mp2' || temp == 'mpa' || temp == 'mpc' || temp == 'ape' || temp == 'ofe' || temp == 'ofr' || temp == 'ogg' || temp == 'r4' ||
            temp == 'wv' || temp == 'tta' || temp == 'ac3' || temp == 'dts') {//音频
            return 'fa-file-audio-o';
        } else if (temp == 'avi' || temp == 'asf' || temp == 'wmv' || temp == 'avs' || temp == 'flv' || temp == 'mkv' || temp == 'mov' || temp == '3gp' ||
            temp == 'mp4' || temp == 'mpeg' || temp == 'dat' || temp == 'ogm' || temp == 'vob' || temp == 'rm' || temp == 'rmvb' || temp == 'ts' || temp == 'tp' ||
            temp == 'ifo' || temp == 'nsv') {//视频
            return 'fa-file-movie-o';
            //BMP、JPG、JPEG、PNG、GIF
        } else if (temp == 'bmp' || temp == 'jpg' || temp == 'jpeg' || temp == 'png' || temp == 'gif') {//图片
            return 'fa-file-image-o';
        } else if (temp == 'xml') {
            return 'fa-file-excel-o';
        } else if (temp == 'pdf') {
            return 'fa-file-pdf-o';
        } else if (temp == 'docx' || temp == 'doc' || temp == 'dot' || temp == 'docm') {
            return 'fa-file-word-o';
        } else if (temp == 'xlsx' || temp == 'xls') {
            return 'fa-file-excel-o';
        } else if (temp == 'pptx' || temp == 'ppt' || temp == 'pot') {
            return 'fa-file-powerpoint-o';
        } else if (temp == 'java' || temp == 'css' || temp == 'js' || temp == 'html' || temp == 'php') {
            return 'fa-file-code-o';
        } else {
            return 'fa-file';
        }
    },
    validationElement: function ($elements) {
        var flag = true;
        $elements.each(function () {
            if (!$(this).validationEngine('validate')) {
                flag = false;
                return false;
            }
        });
        return flag;
    },
    /**
     * 验证用户是否有按钮操作权限
     * @param userRights 用户操作权限 sample -- 1,2,3
     * @param btnRights 按钮权限 sample 1,2
     */
    authenticationAuthority: function (userRights, btnRights) {
        if (!isBlank(userRights)) {
            if (isBlank(btnRights) || btnRights == 'null') {
                return true;
            } else {
                userRights = userRights.split(',');
                btnRights = btnRights.split(',');
                for (var i = 0; i < btnRights.length; i++) {
                    for (var j = 0; j < userRights.length; j++) {
                        if (btnRights[i].trim() == userRights[j].trim()) {
                            return true;
                        }
                    }
                }
                return false;
            }
        } else {
            return true;
        }
    },
    /**
     * 根据选择器初始化自动高度textarea
     * @param selector
     */
    initAutosize: function (selector) {
        var $els = $(selector);
        if ($els.length > 0) {
            $els.autosize();
        }
    },
    /**
     * 初始化富文本编辑器
     * @param selector
     */
    initSummerNoteBySelector: function (selector) {
        tool.initSummerNote($(selector));
    },
    /**
     * 初始化富文本编辑器
     * @param $els
     */
    initSummerNote: function ($els) {
        $els.each(function () {
            var _thisNote = $(this);
            _thisNote.summernote({
                height: 300,
                tabsize: 2,
                lang: 'zh-CN',
                oninit: function () {
                    if (_thisNote.code() == "" || _thisNote.code().replace(/(<([^>]+)>)/ig, "") == "") {
                        _thisNote.code(_thisNote.attr("placeholder"));
                    }
                },
                onfocus: function () {
                    if (_thisNote.code() == _thisNote.attr("placeholder")) {
                        _thisNote.code("");
                    }
                },
                onblur: function () {
                    if (_thisNote.code() == "" || _thisNote.code().replace(/(<([^>]+)>)/ig, "") == "") {
                        _thisNote.code(_thisNote.attr("placeholder"));
                    }
                }
            });
        });
    },
    /**
     * 初始化日期插件
     * @param selector
     */
    initDatetimepickerBySelector: function (selector) {
        tool.initDatetimepicker($(selector));
    },
    /**
     * 初始化日期插件
     * @param $els
     */
    initDatetimepicker: function ($els) {
        if ($els.length > 0) {
            $els.each(function () {
                var el = $(this);
                var config = {};
                config.val = el.val();
                config.format = el.attr("data-format");
                config.minDate = el.attr("data-minDate");
                config.maxDate = el.attr("data-maxDate");
                if (isBlank(config.minDate)) {
                    config.minDate = null;
                }
                if (isBlank(config.maxDate)) {
                    config.maxDate = null;
                }
                config.minDateElement = el.attr("data-min-date-element");
                config.maxDateElement = el.attr("data-max-date-element");
                if (isBlank(config.format)) {
                    config.format = "YYYY-MM-DD";
                }
                config.$maxDateElement = $('#' + config.maxDateElement);
                config.$minDateElement = $('#' + config.minDateElement);

                //如果设置了最大时间
                if (config.maxDateElement != null && config.maxDateElement != '' &&
                    config.$maxDateElement.length > 0 && config.$maxDateElement.attr('data-element-type') == 'datetimepicker') {
                    el.datetimepicker({
                        format: config.format
                    });
                    el.on("dp.change", function (e) {
                        config.$maxDateElement.data("DateTimePicker").minDate(e.date);
                    });

                } else {
                    el.datetimepicker({
                        format: config.format,
                        minDate: config.minDate,
                        maxDate: config.maxDate
                    });
                }

                //如果设置了最小时间
                if (config.minDateElement != null && config.minDateElement != '' &&
                    config.$minDateElement.length > 0 && config.$minDateElement.attr('data-element-type') == 'datetimepicker') {
                    el.datetimepicker({
                        format: config.format,
                        useCurrent: false
                    });
                    el.on("dp.change", function (e) {
                        config.$minDateElement.data("DateTimePicker").maxDate(e.date);
                    });
                } else {
                    el.datetimepicker({
                        format: config.format,
                        minDate: config.minDate,
                        maxDate: config.maxDate
                    });
                }
                if (isBlank(config.val)) {
                    el.val('');
                }
            });
        }

    },
    /**
     * 初始化下拉插件
     * @param selector
     */
    initSelectBySelector: function (selector) {
        tool.initSelect($(selector));
    },
    /**
     * 初始化下拉插件
     * @param $els
     */
    initSelect: function ($els) {
        if ($els.length > 0) {
            $els.each(function () {
                var el = $(this);
                if (!isBlank(el.attr("data-table-name"))) {
                    var table_name = el.attr("data-table-name"); //表名
                    var field_id = el.attr("data-field-id"); //select>value
                    var field_text = el.attr("data-field-name");//select>text
                    var up_file_id = el.attr("data-field-up-id"); //上级过滤字段名
                    var up_file_val = el.attr("data-file-up-val"); //上级过滤字段值 仅需填写第一个
                    var data_field_query = el.attr("data-file-query"); //过滤字段名
                    var data_field_val = el.attr("data-query-val"); //过滤字段值
                    if (isBlank(up_file_val)) up_file_val = "";
                    if (isBlank(data_field_val)) data_field_val = "";
                    //如果table_name 为 t_sys_code 字典表 field_id field_text up_file_id up_file_val data_field_query 可为空,将自动设置默认值
                    if (table_name == "t_sys_code" || table_name == "v_sys_code") {
                        if (isBlank(field_id) && isBlank(field_text) && isBlank(up_file_id) && isBlank(up_file_val) && isBlank(data_field_query)) {
                            field_id = "zdbm";
                            field_text = "zdmc";
                            // up_file_id = "";
                            // up_file_val = "";
                            // data_field_query = "zdlb";
                        }
                    }
                    if (table_name == "t_sys_depart") {
                        if (isBlank(field_id) && isBlank(field_text) && isBlank(up_file_id)) {
                            field_id = "departid";
                            field_text = "departname";
                            // up_file_id = "updepartid";
                        }
                    }
                    var data = {
                        "table_name": table_name,
                        "field_id": field_id,
                        "field_text": field_text,
                        "up_file_id": up_file_id,
                        "up_file_val": encodeURI(up_file_val),
                        "data_field_query": data_field_query,
                        "data_field_val": encodeURI(data_field_val),
                        "cur_val": el.attr('data-cur-val'),
                        "order_field": el.attr('data-order-field'),
                        "order_type": el.attr('data-order-type'),
                        "otherQuery": el.attr('data-other-query')
                    };
                    if (isBlank(el.attr("data-childselect"))) {//不是级联
                        loadSelectOption(basePath + "/s/ajax/getDataForSelect", data, el);
                    } else {
                        el.attr('dont-init', 'true');
                        el.on("change", function () {//当级联下拉 改变时,重新加载子下拉框
                            var chlid_select = $(el.attr("data-childselect"));
                            while (chlid_select.length != 0) {//重置所有子下拉
                                chlid_select.html("<option value=''>&nbsp;</option>");
                                initSelect(chlid_select);
                                chlid_select = $(chlid_select.attr("data-childselect"));
                            }
                            var child_object = $(el.attr("data-childselect"));
                            var up_val = child_object.attr('data-cur-val');
                            if (isBlank(up_val)) {
                                up_val = el.val();
                            } else {
                                up_val = el.find("option:selected").attr('data-val');
                            }
                            loadSelectOption(basePath + "/s/ajax/getDataForSelect", {
                                "table_name": child_object.attr("data-table-name"),
                                "field_id": child_object.attr("data-field-id"),
                                "field_text": child_object.attr("data-field-name"),
                                "up_file_id": child_object.attr("data-field-up-id"),
                                "data_field_query": child_object.attr("data-file-query"),
                                "data_field_val": child_object.attr("data-query-val"),
                                "order_field": child_object.attr('data-order-field'),
                                "order_type": child_object.attr('data-order-type'),
                                "cur_val": child_object.attr('data-cur-val'),
                                "up_file_val": up_val,
                                "otherQuery": el.attr('data-other-query')
                            }, child_object);
                        });
                        if (!el.attr("data-noauto-init")) {
                            loadSelectOption(basePath + "/s/ajax/getDataForSelect", data, el);
                        } else {
                            initSelect(el);
                        }
                    }
                } else if (!isBlank(el.attr("data-select-url"))) {
                    loadSelectOption(el.attr("data-select-url"), null, el);
                } else {
                    initSelect(el);
                }
            });
        }
    },
    /**
     * 初始化下拉插件(搜索)
     * @param selector
     */
    initSearchSelectBySelector: function (selector) {
        tool.initSearchSelect($(selector));
    },
    /**
     * 初始化下拉插件(搜索)
     * @param $els
     */
    initSearchSelect: function ($els) {
        if ($els.length > 0) {
            $els.each(function () {
                var url = $(this).attr("data-select-url");
                url = tool.initParams(url);
                $(this).select2({
                    language: "zh-CN",
                    theme: "bootstrap",
                    width: '100%',
                    ajax: {
                        url: url,
                        dataType: 'json',
                        delay: 250,
                        data: function (params) {
                            return {
                                q: encodeURI(params.term)
                            };
                        },
                        processResults: function (data) {
                            return {
                                results: eval(data)
                            };
                        },
                        transport: function (params, success, failure) {
                            var $request = $.ajax(params);

                            $request.then(success);
                            $request.fail(failure);

                            return $request;
                        },
                        cache: true
                    },
                    escapeMarkup: function (markup) {
                        return markup;
                    }, // let our custom formatter work
                    minimumInputLength: 1
                });
            });
        }
    },
    /**
     * 根据选择器初始化iCheck
     * @param selector 选择器
     */
    initiCheckBySelector: function (selector) {
        tool.initiCheck($(selector));
    },
    /**
     * 初始化iCheck
     * @param $els jquery对象
     */
    initiCheck: function ($els) {
        $els.each(function () {
            var $el = $(this);
            if ($.fn.iCheck) {
                if ($el.hasClass('grey')) {
                    $el.iCheck({
                        checkboxClass: 'icheckbox_minimal-grey',
                        radioClass: 'iradio_minimal-grey',
                        increaseArea: '10%'
                    });
                }
                if ($el.hasClass('green')) {
                    $el.iCheck({
                        checkboxClass: 'icheckbox_minimal-green',
                        radioClass: 'iradio_minimal-green',
                        increaseArea: '10%' // optional
                    });
                }
                if ($el.hasClass('teal')) {
                    $el.iCheck({
                        checkboxClass: 'icheckbox_minimal-aero',
                        radioClass: 'iradio_minimal-aero',
                        increaseArea: '10%' // optional
                    });
                }
                if ($el.hasClass('orange')) {
                    $el.iCheck({
                        checkboxClass: 'icheckbox_minimal-orange',
                        radioClass: 'iradio_minimal-orange',
                        increaseArea: '10%' // optional
                    });
                }
                if ($el.hasClass('purple')) {
                    $el.iCheck({
                        checkboxClass: 'icheckbox_minimal-purple',
                        radioClass: 'iradio_minimal-purple',
                        increaseArea: '10%' // optional
                    });
                }
                if ($el.hasClass('yellow')) {
                    $el.iCheck({
                        checkboxClass: 'icheckbox_minimal-yellow',
                        radioClass: 'iradio_minimal-yellow',
                        increaseArea: '10%' // optional
                    });
                }
                if ($el.hasClass('square-black')) {
                    $el.iCheck({
                        checkboxClass: 'icheckbox_square',
                        radioClass: 'iradio_square',
                        increaseArea: '10%' // optional
                    });
                }
                if ($el.hasClass('square-grey')) {
                    $el.iCheck({
                        checkboxClass: 'icheckbox_square-grey',
                        radioClass: 'iradio_square-grey',
                        increaseArea: '10%' // optional
                    });
                }
                if ($el.hasClass('square-red')) {
                    $el.iCheck({
                        checkboxClass: 'icheckbox_square-red',
                        radioClass: 'iradio_square-red',
                        increaseArea: '10%' // optional
                    });
                }
                if ($el.hasClass('square-green')) {
                    $el.iCheck({
                        checkboxClass: 'icheckbox_square-green',
                        radioClass: 'iradio_square-green',
                        increaseArea: '10%' // optional
                    });
                }
                if ($el.hasClass('square-teal')) {
                    $el.iCheck({
                        checkboxClass: 'icheckbox_square-aero',
                        radioClass: 'iradio_square-aero',
                        increaseArea: '10%' // optional
                    });
                }
                if ($el.hasClass('square-orange')) {
                    $el.iCheck({
                        checkboxClass: 'icheckbox_square-orange',
                        radioClass: 'iradio_square-orange',
                        increaseArea: '10%' // optional
                    });
                }
                if ($el.hasClass('square-purple')) {
                    $el.iCheck({
                        checkboxClass: 'icheckbox_square-purple',
                        radioClass: 'iradio_square-purple',
                        increaseArea: '10%' // optional
                    });
                }
                if ($el.hasClass('square-yellow')) {
                    $el.iCheck({
                        checkboxClass: 'icheckbox_square-yellow',
                        radioClass: 'iradio_square-yellow',
                        increaseArea: '10%' // optional
                    });
                }
                if ($el.hasClass('flat-black')) {
                    $el.iCheck({
                        checkboxClass: 'icheckbox_flat',
                        radioClass: 'iradio_flat',
                        increaseArea: '10%' // optional
                    });
                }
                if ($el.hasClass('flat-grey')) {
                    $el.iCheck({
                        checkboxClass: 'icheckbox_flat-grey',
                        radioClass: 'iradio_flat-grey',
                        increaseArea: '10%' // optional
                    });
                }
                if ($el.hasClass('flat-red')) {
                    $el.iCheck({
                        checkboxClass: 'icheckbox_flat-red',
                        radioClass: 'iradio_flat-red',
                        increaseArea: '10%' // optional
                    });
                }
                if ($el.hasClass('flat-green')) {
                    $el.iCheck({
                        checkboxClass: 'icheckbox_flat-green',
                        radioClass: 'iradio_flat-green',
                        increaseArea: '10%' // optional
                    });
                }
                if ($el.hasClass('flat-teal')) {
                    $el.iCheck({
                        checkboxClass: 'icheckbox_flat-aero',
                        radioClass: 'iradio_flat-aero',
                        increaseArea: '10%' // optional
                    });
                }
                if ($el.hasClass('flat-orange')) {
                    $el.iCheck({
                        checkboxClass: 'icheckbox_flat-orange',
                        radioClass: 'iradio_flat-orange',
                        increaseArea: '10%' // optional
                    });
                }
                if ($el.hasClass('flat-purple')) {
                    $el.iCheck({
                        checkboxClass: 'icheckbox_flat-purple',
                        radioClass: 'iradio_flat-purple',
                        increaseArea: '10%' // optional
                    });
                }
                if ($el.hasClass('flat-yellow')) {
                    $el.iCheck({
                        checkboxClass: 'icheckbox_flat-yellow',
                        radioClass: 'iradio_flat-yellow',
                        increaseArea: '10%' // optional
                    });
                }
            }
            $el.on('ifToggled', function (event) {
                $el.blur();
            });
        });
    },
    initvalidationEngine: function (selector) {
        $(selector).validationEngine({
            showOneMessage: true
        });
    },
    /**
     * 显示提示窗口
     * @param title 标题
     * @param content 内容
     * @param animate 动画效果
     */
    openTipWindow: function (icon, title, content, animate) {
        var config = {};
        if (isBlank(animate)) {
            animate = 'fadeInDown'
        }
        if (isBlank(icon)) {//默认为提示图标
            config.icon = 'fa-lightbulb-o';
        } else {
            config.icon = icon;
        }
        config.title = title;
        config.content = content;
        config.animateIn = animate;
        config.animateOut = animate.replace('In', 'Out');
        tool.openTipWindowByConfig(config);
    },
    openTipWindowByConfig: function (config) {
        var id = getNewElementId();
        var _html = '<div id="' + id + '" class="panel panel-white pt10 notifications hide"><div class="panel-body"><div class="row"><div class="col-xs-12">' +
            '<i class="fa fa-times close"></i><i class="icon fa ' + config.icon + '"></i>' +
            '<h2 class="title">' + config.title + '</h2><p class="content">' + config.content + '</p>' +
            '</div></div></div></div>';
        var $panel = $('body').append(_html).find('#' + id);
        $panel.removeClass('hide').removeClass(config.animateIn + ' animated').addClass(config.animateIn + ' animated').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function () {
            $(this).removeClass(config.animateIn + ' animated');
        });
        $panel.find('i.close').click(function () {
            $panel.removeClass(config.animateOut + ' animated').addClass(config.animateOut + ' animated').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function () {
                $(this).removeClass(config.animateOut + ' animated').addClass('hide');
                $panel.remove();
            });
            ;
        });
    },
    runInit: function () {
        var $body = $('body');
        if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) {
            var ieversion = new Number(RegExp.$1);
            if (ieversion <= 8) {
                isIE8 = true;
                $body.addClass('isIE8');
            } else if (ieversion == 9) {
                isIE9 = true;
                $body.addClass('isIE9');
            }
        }
        // Detection for Mobile Device
        if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
            isMobile = true;
            $body.addClass('isMobile');
        }
    }
}
subPage = {
    /**
     * 子页面关闭回调函数
     * 如需要,请在页面重写,每次子页面关闭将重置
     */
    closeCallback: function () {
    },
    /**
     * 保存之后的回调函数
     * @param data 保存结果
     * @param $form_element 表单对象
     */
    save_callback: function (data, $form_element) {
    }
}
/********************** String工具类***************/
//trim去掉字符串两边的指定字符,默去空格
String.prototype.trim = function (tag) {
    if (!tag) {
        tag = '\\s';
    } else {
        if (tag == '\\') {
            tag = '\\\\';
        } else if (tag == ',' || tag == '|' || tag == ';') {
            tag = '\\' + tag;
        } else {
            tag = '\\s';
        }
    }
    eval('var reg=/(^' + tag + '+)|(' + tag + '+$)/g;');
    return this.replace(reg, '');
};
//字符串截取后面加入...
String.prototype.interceptString = function (len) {
    if (this.length > len) {
        return this.substring(0, len) + "...";
    } else {
        return this;
    }
}
//将一个字符串用给定的字符变成数组
String.prototype.toArray = function (tag) {
    if (this.indexOf(tag) != -1) {
        return this.split(tag);
    } else {
        if (this != '') {
            return [this.toString()];
        } else {
            return [];
        }
    }
}
//只留下数字(0123456789)
String.prototype.toNumber = function () {
    return this.replace(/\D/g, "");
}
//保留中文
String.prototype.toCN = function () {
    var regEx = /[^\u4e00-\u9fa5\uf900-\ufa2d]/g;
    return this.replace(regEx, '');
}
//转成int
String.prototype.toInt = function () {
    var temp = this.replace(/\D/g, "");
    return isNaN(parseInt(temp)) ? this.toString() : parseInt(temp);
}
//是否是以XX开头
String.prototype.startsWith = function (tag) {
    return this.substring(0, tag.length) == tag;
}
//是否已XX结尾
String.prototype.endWith = function (tag) {
    return this.substring(this.length - tag.length) == tag;
}
//StringBuffer
var StringBuffer = function () {
    this._strs = new Array;
};
StringBuffer.prototype.append = function (str) {
    this._strs.push(str);
};
StringBuffer.prototype.toString = function () {
    return this._strs.join("");
};
String.prototype.replaceAll = function (s1, s2) {
    return this.replace(new RegExp(s1, "gm"), s2);
}
function isFunction(fn) {
    return Object.prototype.toString.call(fn) === '[object Function]';
}
/**
 * 获取随机数
 * @returns {*}
 */
function getNewElementId() {
    var temp = tool.randomString(3);
    return temp + (Math.floor(Math.random() * 10000));
}

/**
 * 初始化语言
 */
function init_lanagure() {
    //var uulanguage = (navigator.language || navigator.browserLanguage).toLowerCase();
    try {
        if (cookielang != "" && cookielang != null) {
            if (cookielang == "zh") {
                $("#ddlSomoveLanguage").val("zh");
                $("[data-localize]").localize("text", {pathPrefix: "lang", language: "zh"});
            }
            if (cookielang == "en") {
                $("#ddlSomoveLanguage").val("en");
                $("[data-localize]").localize("text", {pathPrefix: "lang", language: "en"});
            }
        } else {
            $("[data-localize]").localize("text", {pathPrefix: "lang", language: "zh"});
            /* if (uulanguage.indexOf("en") > -1) {
             $("[data-localize]").localize("text", {pathPrefix: "lang", language: "en"});
             SetCookie(name,'en');
             }else if (uulanguage.indexOf("zh") > -1) {
             $("[data-localize]").localize("text", {pathPrefix: "lang", language: "zh"});
             SetCookie(name,'zh');
             }else{
             $("[data-localize]").localize("text", {pathPrefix: "lang", language: "en"});
             };  */
        }
    } catch (e) {
        // TODO: handle exception
        $("[data-localize]").localize("text", {pathPrefix: "lang", language: "zh"});
    }

}


/**
 * 初始化select2插件
 * @param el
 */
function initSelect(el) {
    var minimumResultsForSearch = Infinity;
    if (el.attr("data-show-searchbox")) {
        minimumResultsForSearch = 0;
    }
    var val = el.attr("data-val");
    if (isBlank(val)) {
        val = el.attr("data-value");
    }
    var defaultvalue = el.attr('defaultvalue');
    if (defaultvalue != undefined && defaultvalue != 'undefined' && defaultvalue != null && defaultvalue != ''
        && ($('#wid').val() == null || $('#wid').val() == '')) {
        val = defaultvalue;
    }
    if (!isBlank(val)) {
        el.val(val.split(","));
    }
    var childselect = el.attr("data-childselect");
    if (!isBlank(childselect)) {
        el.change();
    }
    var formatState = el.attr("data-format");
    if (!isBlank(formatState)) {
        formatState = new Function('data', formatState);
        el.select2({
            minimumResultsForSearch: minimumResultsForSearch,
            templateResult: formatState,
            templateSelection: formatState,
            theme: "bootstrap",
            width: '100%'
        });
    } else {
        el.select2({
            minimumResultsForSearch: minimumResultsForSearch,
            theme: "bootstrap",
            width: '100%'
        });
        // el.trigger("change");
    }
}
function loadSelectOption(url, data, el) {
    var data_show_id = el.attr("data-show-id"); //是否显示编码
    $.ajax({
        url: tool.initParams(url),
        type: "post",
        data: data,
        dataType: "json",
        timeout: 1000 * 20,
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            el.html("").append("<option value=''>数据加载失败</option>");
            initSelect(el);
        },
        success: function (data) {
            data = eval(data);
            if (data.data == 'login') {
                tool.alertLogin();
            } else {
                el.html("").append("<option value=''>&nbsp;</option>");
                if (data != null) {
                    for (var i = 0; i < data.length; i++) {
                        if (data_show_id == '1')
                            el.append('<option data-val="' + data[i].curVal + '" value="' + data[i].id + '">' + data[i].text + '(' + data[i].id + ')</option>');
                        else
                            el.append('<option data-val="' + data[i].curVal + '" value="' + data[i].id + '">' + data[i].text + '</option>');
                    }
                }
                initSelect(el);
            }
        }
    });
}